參考鏈接:
https://www.youtube.com/watch?v=nXLnx8ncZyE
sed命令
sed據(jù)我了解是linux中用于替換的一個命令。
使用方法
僅替換第一次出現(xiàn)的:
# 把a.txt中的 abc 換成 def 并打印出來。
sed 's/abc/def/' a.txt
# 把a.txt中的 abc 換成 def ,替換到源文件內(nèi)
sed -i 's/abc/def/' a.txt
# 使用/之外的分隔符也可以搜索,只要你把分隔符放在s后面,比如這里用英文點號
sed -i 's.abc.def.' a.txt
替換所有出現(xiàn)的:
# 把a.txt中的 abc 換成 def 并打印出來。
sed 's/abc/def/g' a.txt