Bo's Oracle Station

查看: 2951|回复: 0

课程第24次

[复制链接]

75

主题

115

帖子

2724

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2724
发表于 2019-6-5 01:44:32 | 显示全部楼层 |阅读模式
2019-06-04
------------------------------
%post
KS_IPADDR=$(ifconfig | head -n 2 | tail -n 1 | cut -c 14- | cut -d ' ' -f 1)
KS_IPADDR_SHORT=$(ifconfig | head -n 2 | tail -n 1 | cut -c 14- | cut -d ' ' -f 1 | cut -d '.' -f 4)
KS_DEVICE=$( ls /etc/sysconfig/network-scripts/ifcf* | grep -v ifcfg-lo | cut -d '/' -f 5)
KS_DEVICE_SHORT=$( ls /etc/sysconfig/network-scripts/ifcf* | grep -v ifcfg-lo | cut -d '/' -f 5 | cut -d '-' -f 2)
cat > /etc/sysconfig/network-scripts/$KS_DEVICE <<EOF
DEVICE=$KS_DEVICE_SHORT
IPADDR=$KS_IPADDR
NETMASK=255.255.255.0
GATEWAY=192.168.0.254
EOF
echo "station$KS_IPADDR_SHORT.example.com" >/etc/hostname
echo "$KS_IPADDR  station$KS_IPADDR_SHORT.example.com  station$KS_IPADDR_SHORT" >> /etc/hosts
%end
----------------------------------
[root@instructor labs]# grep cat 1.txt
cat
concatenate
category
educated
vindication
[root@instructor labs]# grep '^cat' 1.txt
cat
category
[root@instructor labs]# grep dog  1.txt
dog
dogma
boondoggle
chilidog
[root@instructor labs]# grep 'dog$'  1.txt
dog
chilidog
[root@instructor labs]# vim 1.txt
[root@instructor labs]# grep '^#'  1.txt
#dog
#cat
[root@instructor labs]# grep -v  '^#'  1.txt
cat
dog
concatenate
dogma
category
educated
boondoggle
vindication
chilidog
[root@instructor labs]# grep '^#'  1.txt
#dog
#cat
[root@instructor labs]# grep '^$'  1.txt
[root@instructor labs]# grep  -v '^$'  1.txt
cat
dog
concatenate
dogma
category
educated
boondoggle
vindication
chilidog
#dog
#cat
[root@instructor labs]# grep  -v '^$'  1.txt |  grep -v '^#'
cat
dog
concatenate
dogma
category
educated
boondoggle
vindication
chilidog
[root@instructor labs]#
--------------------------
[root@instructor labs]# grep -A 1 -B 1  -n  --color  -r '\<cat\>'  ./
./2.txt:1:cat
./2.txt-2-cbt
--
./1.txt:1:cat
./1.txt-2-dog
--
./1.txt-11-
./1.txt:12:#cat
./1.txt-13-This is cat1


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-5-7 17:48 , Processed in 0.099754 second(s), 24 queries .

快速回复 返回顶部 返回列表