#復制/etc/profile至/tmp/目錄,用查找替換命令刪除/tmp/profile文件中的行首的空白字符
vim /tmp/profile
%s@^[[:space:]]+@@g
#復制/etc/rc.d/init.d/functions文件至/tmp目錄,用查找替換命令為/tmp/functions的每行開頭為空白字符的行的行首添加一個#號
vim /tmp/functions
%s@^([[:space:]]+.)@#\1@g
#在vim中設置tab縮進為4個字符
vim ~/.vimrc
set ts=4
set expandtab
:wq!
#復制/etc/rc.d/init.d/functions文件至/tmp目錄,替換/tmp/functions文件中的/etc/sysconfig/init為/var/log
%s@/etc/sysconfig/init@/var/log@g
#刪除/tmp/functions文件中所有以#開頭,且#后面至少有一個空白字符的行的行首的#號
%s@^#([[:space:]]+.)@\1@g
#編寫腳本/root/bin/systeminfo.sh,顯示當前主機系統信息,包括主機名,IPv4地址,操作系統版本,內核版本,CPU型號,內存大小,硬盤大小
#!/bin/bash
#discription:hostname,ifconfig,uname,lscpu,/etc/redhat-release,free,df
echo “starting showing”
sleep 1
htnm=hostname
echo “internetname is $htnm”
ip=ifconfig | egrep -o "\<(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\>"
echo “ip adress is $ip”
klvn=uname -r
echo “kernolversion is $klvn”
CPUinfo=lscpu|grep -i "model name"
echo “CPUinfomation is $CPUinfo”
sysvn=cat /etc/redhat-release
echo “systemversion is $sysvn”
rfree=free -m | grep Mem | tr -s " " ":" | cut -d : -f4
echo “roomfree is $rfree”
dius=df -h | grep "/dev/sd" | tr -s " " "%"|cut -d % -f 5
echo ” disk_usage is $dius”
echo “finishing showing “
unset htnm
unset ip klvn CPUinfo sysvn rfree dius
#編寫腳本/root/bin/links.sh,顯示正連接本主機的每個遠程主機的IPv4地址和連接數,并按連接數從大到小排序
#!/bin/bash
#discription:ipv4 address and link number
echo “starting showing”
sleep 1
ipv4lk=netstat -nt |tr -s " " : |cut -d : -f6 | egrep '([0-9]+.){3}[0-9]+' |sort|uniq -c
echo “ipv4 address and link number is $ipv4lk”
echo “finishing showing”
unset ipv4lk
原創文章,作者:Miracle,如若轉載,請注明出處:http://www.www58058.com/77400