预习作业(四)作业

#!/bin/bash
#
#*************************************************************
#Author:                         lideyuan
#QQ:                             827931744
#Date:                           2020-05-05
#FileName:                       /data/systemindo.sh
#URL:                            http://www.lidyeyuan.com
#Description:                    Host System Information
#Copyright (C):                  2020 All rights reserved
#*************************************************************
echo -e "\033[$[$RANDOM%6+31];1mHostname:       $(hostname)\033[0m"
echo -e "\033[$[$RANDOM%6+31];1mIPv4 Address:   $(ifconfig|sed -nr '2p'|tr -s " "|cut -d" " -f3)\033[0m"
echo -e "\033[$[$RANDOM%6+31];1m:System version:$(cat  /etc/redhat-release)\033[0m"
echo -e "\033[$[$RANDOM%6+31];1mKernel:         $(uname -r)\033[0m"
echo -e "\033[$[$RANDOM%6+31];1mCpu:           $(lscpu |grep "Model name"|tr -s ' '|cut -d: -f2)\033[0m"
echo -e "\033[$[$RANDOM%6+31];1mMemory Size:    $(free -h |sed -nr '2p'|tr -s " "|cut -d" " -f2)\033[0m"
echo -e "\033[$[$RANDOM%6+31];1mDisk:           $(lsblk|sed -nr '2p'|tr -s " "|cut -d" " -f4
)\033[0m"

2、

#!/bin/bash
echo "start bakup"
sleep 2
cp -a /etc/ /root/etc`date +%F-%T`
echo "finished"

3、

#!/bin/bash
echo -e "\033[34;1mLargest Disk Availability:`df -h|grep "^/dev/sd"|tr -s " " %|cut -d% -f5|sort -nr|head -1`%\033[0m"

4、

#!/bash/bin
netstat -tan |tr -s " " ":"|cut -d: -f6|grep ^[[:digit:]]|sort|uniq -c |sort -nr`"

5、sed -i '$a\  ' test.txt

6、sed -n '1~2p' /etc/passwd

posted @ 2020-05-05 10:05  ldyaly  阅读(123)  评论(0编辑  收藏  举报