Skip to content

Instantly share code, notes, and snippets.

@cuihaoleo
Created January 29, 2013 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuihaoleo/4660944 to your computer and use it in GitHub Desktop.
Save cuihaoleo/4660944 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 使用:replace.sh <替换列表> <被替换的文件>
# 忽略大小写,单词后加一个s会被当成复数视为同一单词,空格要用"\ "转义
# 示范:https://gist.github.com/4660920
cat $1 | while read src dest do sed -i -r "s/(\<${src}s?\>)/\1($dest)/ig" $2 done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment