#复制/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.178linux.com/77400