find and replace text SUSE
I am working on replacing a word throughout all my directories.
I did some research and found the "sed" command So I created a bunch of text files with the word "Jill" in it. The text I created was put in different sub-directories. So I wrote a script to take all the words with "Jill" in it and replace it with "Joan" When I run the commands separately, they work, but when I pipe it together, it acts like I have no input. Here is the script grep -iwr Jill ~/home/*|sed -i 's/Jill/Joan/g' Trying to learn Linux thanks Ron |
Code:
grep -iwr Jill ~/home/*|sed -i 's/Jill/Joan/g' Code:
grep -lwr Jill * | xargs sed -i 's/Jill/Joan/g' |
Instead of piping you could also look at process substitution of the grep (again getting file names) as input to the sed:
Code:
sed -i 's/Jill/Joan/g' $(grep -lwr Jill *) |
Find and Rbeplace SUSE
I still can't make the sed and grep command work together. Maybe I am going about this the wrong way. I just want every instance of a word replaced with another word of my choosing. It has to go to sub-directories and across other directories too?
Looking for some guidance. thanks Ron |
The -r option of grep make it to descend recursively into the directory tree. What's wrong with the suggested commands? Maybe a real example might help us to help you. What have you tried so far? Please, provide as many details as you can.
|
Also, as you keep using a Windows computer, advise if the files are created under Windows as this will also make a difference?
|
All times are GMT -5. The time now is 12:38 AM. |