Skip to content

Instantly share code, notes, and snippets.

@maeharin
Created January 28, 2013 04:25
Show Gist options
  • Save maeharin/4653023 to your computer and use it in GitHub Desktop.
Save maeharin/4653023 to your computer and use it in GitHub Desktop.
ruby one liner oneliner sub gsub sh
# マッチした最初の文字を置換
cat hoge.txt | ruby -pe '$_.sub!("hoge", "fuge")' > fuge.txt
# マッチした全ての文字を置換
cat hoge.txt | ruby -pe '$_.gsub!("hoge", "fuge")' > fuge.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment