Feature #640
Using Sed To Replace a String In Multiple Files
Status:
Closed
Priority:
Normal
Assignee:
Category:
Development Environment
Target version:
Description
This is a guide for using the sed utility to replace a string in multiple files.
- Switch to the working folder to run the command in:
cd /usr/local/www/
- Then use sed to replace all instances of foo with bar in all files in the working directory:
sed -i 's/foo/bar/g' *
- Alternatively, if there are folders in the working directory you may want to recirsively find all files and apply the replacement to them. This can be accomplished by running:
find . -type f -exec sed -i 's/foo/bar/g' {} ;
Resources¶
Updated by Daniel Curtis over 9 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100