Score:0

Replace a string from the cat output

co flag

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

jp flag
Single quotes are preventing `$(cat ..)` from expansion. Use double-quotes.
Am3Y avatar
co flag
@AlexD Thanks bro it worked :-)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.