1,sed匹配两种重要思想
屏蔽思想:遮住不想要的
挑出思想:遮住所有,挑出想要的.
2,实例
屏蔽思想:
[[email protected] ~]# sed -n ‘2p‘ file.txt |sed -r ‘s#fox##g‘ [email protected]
全匹配,挑出思想:
2.1
问题:echo "I am lanny teacher"过滤lanny.
[[email protected] ~]# echo "I am lanny teacher"|sed -r ‘s#^.*am ([a-z].*) te.*$#\1#g‘ lanny
2.2
问题:echo "[email protected]"过滤foxmail.
[[email protected] ~]# echo "[email protected]"|sed -r ‘s#^.*@([a-z].*)\..*$#\1#g‘ foxmail
时间: 2024-11-10 19:09:45