Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
docs:bash:search_and_replace_in_files [2009/05/29 11:31] – created billh | docs:bash:search_and_replace_in_files [2009/06/03 10:45] (current) – billh | ||
---|---|---|---|
Line 1: | Line 1: | ||
===== Search and Replace in Files ===== | ===== Search and Replace in Files ===== | ||
< | < | ||
- | grep -Z -R -l -e 'searchstring' . | xargs -0 sed -i 's/searchstring/ | + | grep -Z -R -l -E 'searchpattern' . | xargs -0 sed -i 's/searchpattern/ |
</ | </ | ||
+ | |||
+ | ===== Advanced Example ===== | ||
+ | * :!: remember to escape parenthesis when using [[sed]] | ||
+ | * this example finds all occurrences of ' | ||
+ | < | ||
+ | grep -Z -R -l -E ' | ||
+ | </ | ||
+ | |||
+ | ===== FreeBSD 5 Example ===== | ||
+ | * the -Z parameter was different for grep, so it actually wanted %%--null%% | ||
+ | * the backup extension for sed was not optional, so ' | ||
+ | < | ||
+ | grep --null -R -l -E ' | ||
+ | </ | ||
+ | |||
+ | ===== See Also ===== | ||
+ | * [[sed]] | ||
+ |