how to use xargs with sed in search pattern

前端 未结 4 1519
再見小時候
再見小時候 2020-12-29 06:36

I need to use the output of a command as a search pattern in sed. I will make an example using echo, but assume that can be a more complicated command:

echo          


        
4条回答
  •  一生所求
    2020-12-29 07:33

    You need to tell xargs what to replace with the -I switch - it doesn't seem to know about the {} automatically, at least in some versions.

    echo "pattern" | xargs -I '{}' sed -i 's/{}/replacement/g' file.txt
    

提交回复
热议问题