Skip to content

Instantly share code, notes, and snippets.

@onjiro
Created February 7, 2012 05:45
Show Gist options
  • Save onjiro/1757492 to your computer and use it in GitHub Desktop.
Save onjiro/1757492 to your computer and use it in GitHub Desktop.
grep して 置換するよー。sed -i が使えればこんな面倒なことはいらないッ・・・!
# 次の置換と同じ。
# grep -lre h1 検索対象ディレクトリ | xargs sed -i 's/h1/h2/g'
grep -lre 'h1' 検索対象ディレクトリ | xargs -n 1 -i sh "cp {} tmp; sed -e 's/h1/h2/g' ./tmp > {}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment