/ Published in: Bash
As portrayed by the example found in the Advanced Bash Scripting guide this demonstrates a few techniques
Expand |
Embed | Plain Text
#!/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
You need to login to post a comment.
