Replace string in files

From snippet wiki
Jump to navigation Jump to search

Need to update a single string in multiple files? Maybe a year in the footer of many html files?

sed -i 's/ 2012 Company/ 2014 Company/g' *.html

That should match all html files in the current directory. Be strict with the pattern, otherwise you might change prices, ISBNs and many more substrings. Surround the year with whitespace in both patterns.