admin 发表于 2019-6-5 01:44:32

课程第24次

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_IPADDRstation$KS_IPADDR_SHORT.example.comstation$KS_IPADDR_SHORT" >> /etc/hosts
%end
----------------------------------
# grep cat 1.txt
cat
concatenate
category
educated
vindication
# grep '^cat' 1.txt
cat
category
# grep dog1.txt
dog
dogma
boondoggle
chilidog
# grep 'dog$'1.txt
dog
chilidog
# vim 1.txt
# grep '^#'1.txt
#dog
#cat
# grep -v'^#'1.txt
cat
dog
concatenate
dogma
category
educated
boondoggle
vindication
chilidog
# grep '^#'1.txt
#dog
#cat
# grep '^$'1.txt
# grep-v '^$'1.txt
cat
dog
concatenate
dogma
category
educated
boondoggle
vindication
chilidog
#dog
#cat
# grep-v '^$'1.txt |grep -v '^#'
cat
dog
concatenate
dogma
category
educated
boondoggle
vindication
chilidog
#
--------------------------
# 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


页: [1]
查看完整版本: 课程第24次