1

I need to replace a string with the string which is mentioned in a file abcd.txt in all files in a folder.

For eg: I want to replace a string 'apple' with whatever the cat output of this file abcd.txt

I used the below command

grep -rl 'apple' /home/ron/log/temp | xargs sed -i 's/apple/$(cat /home/ron/output/id-3.txt)/g';

I'm getting the below error while doing it.

sed: -e expression #1, char 23: unknown option to `s'

Can anyone please help me on this

1
  • 2
    Single quotes are preventing $(cat ..) from expansion. Use double-quotes.
    – AlexD
    Jan 24, 2022 at 17:15

0

You must log in to answer this question.

Browse other questions tagged .