find with grep and replace it
I want to find a string in a directory (Recursively) and replace it with another string.
Is there any relevant command to do the job? |
grep is really only for finding matches; it doesn't do anything by way of replacing. sed (stream editor) is probably closer to what you're looking for. perl can also do it fairly easily, if you have that installed. Check out Searching and Replacing (Linux Cookbook).
|
what is [RET] ?
|
there are the error that i received
Code:
|
[RET] I presume is the enter key.
It looks like it's giving errors on all the directory names; I don't think that command will do replacing on directories, just on the files that are in the current directory. You could do all the subdirectories manually, but that would be a pain if there are a lot of them. An easier way would be to use a find command on all the files you want to replace (for example, all *.html files), and then run sed on each one. Something like this: find . -name '*.html' -exec sed -e "s/htmlentities//g;" The first part (find . -name '*.html') finds all files in the current directory and all subdirectories with an html extension. The second part (-exec and so on) tells find to run the given sed command on each file it finds. I'm not sure about the syntax, so you may want to search around for sed howtos. |
All times are GMT -5. The time now is 06:05 AM. |