This is the best command line I have ever found to search and replace text into files within directories, sub directories.
Command:
Example:
find searching_dir -name .dir_name_to_prune -prune -o -exec sed -i 's/Searched Text/Replacing Text /g' {} \;
find . -name .svn -prune -o -exec sed -i 's/Powered by: /Site Developed by /g' {} \;
Description:find : the find command
. : current directory (you can set other)
name : name the file list
svn : the svn dir will be prouned
prune : used to prune dirs/files
o : options
exec : executind sed command
sed : the sed command
i : this will insert new text while searched text matches
's/ : this will search for finding matches
/g' : make the operation globally.
{} \; : Out put and termanating the command line
. : current directory (you can set other)
name : name the file list
svn : the svn dir will be prouned
prune : used to prune dirs/files
o : options
exec : executind sed command
sed : the sed command
i : this will insert new text while searched text matches
's/ : this will search for finding matches
/g' : make the operation globally.
{} \; : Out put and termanating the command line
Thats all, this works nice.....
the current directory is not working. but when I used *.* instead of . then it worked.
ReplyDeletefind *.php -name .svn -prune -o -exec sed -i 's/skin_blue/skin_silver/g' {} \;
ReplyDeletethis works for all php files in directories