Edit each line in a file in Ruby

后端 未结 5 963
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 02:52

I\'m trying to find a simple way of editing each line in a file, and I\'m having some trouble understanding how to use the File class to do so.

The file

5条回答
  •  时光说笑
    2020-12-14 03:47

    Another way to modify the file inplace is to use the -i switch

    ruby -F"," -i.bak -ane 'puts $F[0]' file
    

提交回复
热议问题