Revision: 60110
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 20, 2012 17:51 by symsec
Initial Code
#!/usr/bin/env bash # Replace all instances of "Smith" with "Jones" #+ in files with a ".txt" filename suffix. ORIGINAL=Smith REPLACEMENT=Jones for word in $(fgrep -l $ORIGINAL *.txt) do # ------------------------------------- ex $word <<EOF :%s/$ORIGINAL/$REPLACEMENT/g :wq EOF # :%s is the "ex" substitution command. # :wq is write-and-quit. # ------------------------------------- done
Initial URL
Initial Description
As portrayed by the example found in the [Advanced Bash Scripting guide](http://tldp.org/LDP/abs/html/here-docs.html) this demonstrates a few techniques
Initial Title
Bash exscript to replace word occurrences
Initial Tags
regex, script, replace
Initial Language
Bash