I have a text file named abcd.txt which has content dfunsufngsufspdfnsufbhpsdubf
I have multiple php files, py files in a folder names /home/admin/temp
All the files have a string replace-me
How can I replace this? I tried using the below script
NODE=1
BOY="/home/opc/firewall"
GIRL="$BOY/full/temp-$NODE"
grep -rl 'replace-me' $GIRL | xargs sed -i "s/replace-me/$(cat $GIRL/abcd3.txt)/g";
I'll be using this in a big script. Someone please help me in such case
CodePudding user response:
Suggesting to feed result from grep
command to sed
command:
sed -i "s/replace-me/$(cat $GIRL/abcd3.txt)/g" $( grep -rl 'replace-me' $GIRL )