sed

1、sed(上)

命令格式:
sed '//' test.txt
sed -n '//'p test.txt
打印出test.txt文件:
sed '/root/'p test.txt
sed
過濾出只帶root的行:
sed -n '/root/'p test.txt
sed
過濾出帶有ot的行:
sed -nr '/o+t/'p test.txt
sed
過濾出帶有兩個o的行:
sed -nr '/o{2}/'p test.txt
sed
過濾出帶有root或者bus的行:
sed -nr '/root|bus/'p test.txt
sed
打印出第二行:
sed -n '2'p test.txt
sed
打印出2到5行:
sed -n '2,5'p test.txt
sed
打印出25行以後的行:
sed -n '25,$'p test.txt
sed
打印出第一行和匹配bus的行:
sed -e '1'p -e '/bus/'p -n test.txt
sed
打印出第一行和匹配root的行,會打印兩次:
sed -e '1'p -e '/root/'p -n test.txt
sed
打印出第一行和匹配root、oo的行
sed -e '1'p -e '/root/'p -e '/oo*/'p -n test.txt
sed

2、sed(下)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章