第十八天

第十八天

取出ifconfIg ens33命令中本机的IPv4地址 可以百度扩展 了解即可 记不住也没事 不常用

ifconfig ens33 | egrep -o 'inet [0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/' |egrep -o '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'

把/etc/passwd 复制到/root/test.txt,用sed打印所有行

cp /etc/passwd /root/test.txt
sed -n '/^$/!p' /root/test.txt

打印test.txt的3到10行

sed -n '3,10p' /root/test.txt

打印test.txt 中包含 ‘root’ 的行

grep 'root' /root/test.txt

删除test.txt 的15行以及以后所有行

sed '15,$d' /root/test.txt

删除test.txt中包含 ‘bash’ 的行

sed '/bash/d' /root/test.txt

替换test.txt 中 ‘root’ 为 ‘ha’

sed 's/root/ha/g'  /root/test.txt

替换test.txt中 ‘/sbin/nologin’ 为 ‘/bin/login’

sed 's#/sbin/nologin#/bin/login#g' /root/test.txt

打印/etc/passwd的奇数行?

sed -n 'n;p' /etc/passwd

把/etc/httpd/conf/httpd.conf?件内的Linsten 80改为Listen 8081 sed 完成

sed -i 's/Listen 80/Listen 8081/g' /etc/httpd/conf/httpd.conf
posted @ 2024-03-10 21:19  三思博客  阅读(6)  评论(0编辑  收藏  举报