關於sed的詳細命令見此鏈接:man.linuxde.net/sed
替換指定行
(1) 查找aaa.txt中包含xxxx的行號
LINE_NUM=$(sed -n '/xxxx/=' aaa.txt)
(2)替換指定行號為yyyy
sed $OPTS "$LINE_NUM"'c yyyy‘ aaa.txt
ps:因為我使用的場景中包含xxxx的行只有一行,如果多行還要進行判斷