Well I am going to be honest, I am actually a chemist
I am trying to get into computational chemistry and this is NOT homework. I am trying to use a docking software and this is to customize a trillion .sh files for the linux cluster (I am going to write the path of the command in the .sh script).
Thanks for the advice, I have read about the -i option, I am experimenting with it but the main problem is that there is no recursive option for sed. I have found a couple of examples with xargs they didn't work either (and several more with other commands), I will try a couple more things and post results soon.
Thanks again people
---------- Post updated at 12:47 PM ---------- Previous update was at 01:21 AM ----------
Ah I figured it out
I now realize this was incredibly easy but I needed more knowledge, thanks a lot for your help
What I did was I used grep as you've said to find the proper files and piped it through xargs to use sed on them. I didn't know both grep and xargs but I've read the manuals and I played around with them. Thanks again
The exact code I used;
grep -rl 'string' */ | xargs sed -i 's: oldstring:newstring:'
The reason I used : s in sed was that I was using a string with a lot of / s (the path). I used */ because I am going to make a small .sh file using this and I didn't want to edit the file to set the path every single time. I am a happy man
Also I am going to play around with the find command as methyl said since I think listing .sh files is a better option in my case. But this works for now
-Edit
I have played around with find (thanks again methyl) and I think this is the best code for me;
find ./*/ -type f -name '*.sh' -print | xargs sed -i 's: oldstring : newstring :'
Works perfectly ^^ I will eventually add a backup feature (-i.bak maybe?) into this but I am done for now.
Now I need to actually do the chemistry bit of this