Bash exscript替换出现的单词
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Bash exscript替换出现的单词相关的知识,希望对你有一定的参考价值。
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
#!/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
以上是关于Bash exscript替换出现的单词的主要内容,如果未能解决你的问题,请参考以下文章