Skip to main content
1 of 3
Krackout
  • 2.9k
  • 1
  • 15
  • 28

sed in conjuction with xargs and grep not working

I'm trying to change a string in multiple text files (configurations migrated to other user). I used this command:

grep -iIlr "/home/user/.local" | xargs sed -i 's/\/home\/user\/\.local/~\/\.local/g'

also tried this:

grep -iIlr "/home/user/.local" | xargs -d '\n' sed -i "s/\/home\/user\/\.local/~\/\.local/g"

They don't work. Errors is produced by sed,

sed: can't read {path/file which is valid}: No such file or directory

grep alone gives a decent list of files. No special characters on file names, I think not spaces also (not fully certain about this). Isn't xargs passing a proper list?

OS: RHEL 8.10 fully updated,
GNU grep v 3.1,
GNU sed 4.5,
xargs (GNU findutils) 4.6.0

Krackout
  • 2.9k
  • 1
  • 15
  • 28