Skip to content

Latest commit

 

History

History
15 lines (13 loc) · 488 Bytes

sed.md

File metadata and controls

15 lines (13 loc) · 488 Bytes

sed usage

Combination with find

Apply sed to files found by the find command:

$ find path/to/specify -iname \*.txt -exec sed -e "s#old_pattern#new_pattern#g" {} -i-old \;

Note the usage of option -i-old which keeps a backup of the modified file (e.g., test.txt -> test.txt-old).

You may also want to apply a cautious strategy (by replacing -exec with -ok):

$ find path/to/specify -iname \*.txt -ok sed -e "s#old_pattern#new_pattern#g" {} -i-old \;