Skip to content

Instantly share code, notes, and snippets.

@froop
Created July 7, 2011 07:52
Show Gist options
  • Select an option

  • Save froop/1069063 to your computer and use it in GitHub Desktop.

Select an option

Save froop/1069063 to your computer and use it in GitHub Desktop.
[bsh] 複数ファイルの内容を一気に書き換えるシェルスクリプトのサンプル for Cygwin
mkdir result
for FILE in *.txt; do sed -e '1,3d' -e 's/\b9999\b/0001/g' -e '/^REM\b/d' $FILE > result/$FILE; unix2dos result/$FILE; done
# カレントディレクトリの「*.txt」ファイルが対象
# 「-e '1,3d'」1行目から3行目を削除
# 「-e 's/\b9999\b/0001/g'」正規表現に合致する文字列を置換
# 「-e '/^REM\b/d'」正規表現に合致する行を削除
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment