LoginSignup
0
0

More than 5 years have passed since last update.

tr を ruby で ( シリーズ: Ruby ワンライナ ちょっとづつ 0 )

Last updated at Posted at 2016-11-11

sedtr を捨てたいのでちょっとづつ Ruby ワンライナを学ぶ.

参考

これまで

cat foo.txt | tr 'a' 'b'

これから

cat foo.txt | ruby -pe '$_.gsub!("a", "b")'

所見・所感

これだけだと tr の方がタイプ数が少なくて楽そうに見える.しかし,これより複雑なことをしようと思うと sed に頼ることになる. trsed をそれぞれ習得するよりは Ruby でいろいろできた方が楽そうだ.

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0