Replacing first occurance of a match with sed

前端 未结 3 1844
闹比i
闹比i 2021-01-07 03:25

I am doing a find and replace with sed, replacing the BASH variable $a (when at the start of a new line) with the BASH variable $b:



        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-07 04:00

    This should work:

    sed -i "0,/^\$a/s//\$b/" ./file.txt
    

    You can read more about this at http://www.grymoire.com/Unix/Sed.html#toc-uh-29

提交回复
热议问题