ardabro
ardabro

Reputation: 2061

How to redirect a list of files to sed and modify them inplace?

I would like to do sth like this:

grep --files-with-matches <pattern> * | sed -i <pattern>

Which means: take a list of files generated by grep and modify each of them inplace. Is it possible in one-liner ?

Upvotes: 0

Views: 52

Answers (1)

SMA
SMA

Reputation: 37063

Try this:

grep -l <pattern> * | xargs sed -i 's/replaceFrom/replaceTo/g'

Upvotes: 1

Related Questions