find . -type f -exec grep -il "text to find" {} \;
Will give you a list of all the files that contain "text to find", starting with your current directory and searching all sub-directories.
Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts
Friday, June 26, 2009
Tuesday, June 9, 2009
Useful unix command to find and replace text in many files
Here is a useful unix command I used today to find and replace text across multiple files and multiple directories.
find . -type f -exec sed -i "s/string1/string2/g" {} \;
This will replace all instances of string1 with string2.
Credit to Google and http://www.sb.fsu.edu/~soma/Proj/How-to/Search+Replace.pdf for helping me figure this out.
find . -type f -exec sed -i "s/string1/string2/g" {} \;
This will replace all instances of string1 with string2.
Credit to Google and http://www.sb.fsu.edu/~soma/Proj/How-to/Search+Replace.pdf for helping me figure this out.
Subscribe to:
Posts (Atom)