1、取本机ip地址
[[email protected] ~]# ifconfig eth1 Link encap:Ethernet HWaddr 00:0C:29:35:DD:AB inet addr:10.1.253.95 Bcast:10.1.255.255 Mask:255.255.0.0 inet6 addr: fe80::20c:29ff:fe35:ddab/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:378023 errors:0 dropped:0 overruns:0 frame:0 TX packets:12444 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:46926222 (44.7 MiB) TX bytes:1240063 (1.1 MiB) eth2 Link encap:Ethernet HWaddr 00:0C:29:35:DD:B5 inet addr:192.168.226.135 Bcast:192.168.226.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe35:ddb5/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2539 errors:0 dropped:0 overruns:0 frame:0 TX packets:225 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:281133 (274.5 KiB) TX bytes:39650 (38.7 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [[email protected] ~]# ifconfig |awk -F ‘[: ]+‘ ‘NR==2{print $4}‘ 10.1.253.95 [[email protected] ~]# ifconfig eth1 Link encap:Ethernet HWaddr 00:0C:29:35:DD:AB inet addr:10.1.253.95 Bcast:10.1.255.255 Mask:255.255.0.0 inet6 addr: fe80::20c:29ff:fe35:ddab/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:379965 errors:0 dropped:0 overruns:0 frame:0 TX packets:12615 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:47097014 (44.9 MiB) TX bytes:1264173 (1.2 MiB) eth2 Link encap:Ethernet HWaddr 00:0C:29:35:DD:B5 inet addr:192.168.226.135 Bcast:192.168.226.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe35:ddb5/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2541 errors:0 dropped:0 overruns:0 frame:0 TX packets:227 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:281535 (274.9 KiB) TX bytes:40052 (39.1 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [[email protected] ~]# ifconfig |head -2 eth1 Link encap:Ethernet HWaddr 00:0C:29:35:DD:AB inet addr:10.1.253.95 Bcast:10.1.255.255 Mask:255.255.0.0 [[email protected] ~]# ifconfig |head -2 |sed -r ‘s/^.*addr:(.*) Bca.*$/\1/g‘ eth1 Link encap:Ethernet HWaddr 00:0C:29:35:DD:AB 10.1.253.95 [[email protected] ~]# ifconfig |head -2|tail -1 |tr -s ‘ ‘ ‘:‘ |cut -d: -f4 10.1.253.95 [[email protected] ~]#
1.1、取出本机所有的IP地址
[[email protected] ~]# ifconfig |tr -cs ‘[:digit:].‘ ‘\n‘|sort -t. -k4|tail -8 255.0.0.0 255.255.0.0 255.255.255.0 127.0.0.1 192.168.226.135 10.1.255.255 192.168.226.255 10.1.253.95 [[email protected] ~]#
2、取各分区利用率的数值
[[email protected] ~]# df |grep "sd.*" /dev/sda3 121455724 3990720 111288700 4% / /dev/sda1 194241 34082 149919 19% /boot /dev/sdb 20511356 44992 19417788 1% /mnt [[email protected] ~]# df |grep "sd.*"|tr -s ‘ ‘ ‘:‘ /dev/sda3:121455724:3990720:111288700:4%:/ /dev/sda1:194241:34082:149919:19%:/boot /dev/sdb:20511356:44992:19417788:1%:/mnt [[email protected] ~]# df |grep "sd.*"|tr -s ‘ ‘ ‘:‘|cut -d: -f1,5 /dev/sda3:4% /dev/sda1:19% /dev/sdb:1% [[email protected] ~]# df |grep "sd.*"|tr -s ‘ ‘ ‘:‘|cut -d: -f1,5|sort -nr /dev/sdb:1% /dev/sda3:4% /dev/sda1:19% [[email protected] ~]#
3、统计/etc/init.d/functions 文件中每个单词出现的次数,并按频率从高到低显示
[[email protected] ~]# cat /etc/init.d/functions |tr -cs ‘[:alpha:]‘ ‘\n‘|sort|uniq -c |sort-nr 83 if 77 then 75 pid 73 echo 72 fi 61 return 57 dev 54 file 50 n 46 local
4、/etc/rc.d/init.d/functions或/etc/rc.d/init.d/functions/" 取目录名
[[email protected] ~]# echo "/etc/init.d/functions"|sed -r ‘s#^(/.*/)[^/]+/?#\1#g‘ /etc/init.d/ [[email protected] ~]#
4.1、/etc/rc.d/init.d/functions或/etc/rc.d/init.d/functions/" 取基名
[[email protected] ~]# echo "/etc/init.d/functions/"|sed -r ‘s#/.*/([^/]+)#\1#g‘ functions/ [[email protected] ~]#
时间: 2024-10-13 03:14:08