LoginSignup
0
0

More than 3 years have passed since last update.

rubyでファイル末尾の改行を消す

Last updated at Posted at 2020-01-16

git diffしたときの
「\ No newline at end of file」がウザいのでrubyで置換した

・パターン1

ruby -i -ne 'print ARGF.eof? ? $_.chomp : $_' test.txt

・パターン2

ruby -i -e 'print ARGF.read.strip' test.txt

sedでやりたかったな

もっといい方法あれば教えて下さい

viで↓をやるのがめんどくさかった
https://qiita.com/lemtosh469/items/b3a5b3b40d9f44dfbd06

(本当は末尾に改行がある方が正しいらしい)

0
0
0

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