replace - Substitute string in BASH with Sed (when it has special characters) -
it's simple question , i'm sure gurus here can figure out right away, don't seem able make work (probably quotes issue.
i want place instances of:
`which cat`
with following:
/bin/cat
i running following command:
for file in $(find . -iname 'patch*'); sed 's/\`which cat\`/\'\/bin\/cat/g' $file; done
i believe have escaped characters don't need treated special ones, doesn't seem trick.
please :)
it not idea iterate on output of find
since file names can contain $ifs
break loop. use -exec
option of find
instead:
find -iname 'patch*' -exec sed -i 's#`which cat`#/bin/cat#g' {} \;
Comments
Post a Comment