I need to modify a number of files inside a directory. I need to modify all those files which contain particular text and have to replace with some new text.
So I thought of writing a shell script which will traverse through all the subdirectories and modify the content but I’m having problem while traversing the all possible directories.
You can use
findto traverse through subdirectories looking for files and then pass them on tosedto search and replace for text.e.g.
will find all txt files and replace foo with bar in them.
The
-imakes sed change the files in-place. You can also supply a backup-suffix to sed if you want the files backed up before being changed.