LoginSignup
12
11

More than 5 years have passed since last update.

改行コード変換をAWKで

Posted at

改行コード変換はtrやPerlを使うやり方がよく知られているけど、AWKだと、RS (input record separator) や ORS (output record separator) を使うと柔軟に変換できるようだ。

awk -v ORS='\r\n' '{print}' < lf.txt > crlf.txt
awk -v RS='\r\n' '{print}' < crlf.txt > lf.txt
awk -v RS='\r' '{print}' < cr.txt > lf.txt
awk -v RS='\r' -v ORS='\r\n' '{print}' < cr.txt > crlf.txt

などなど。

12
11
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
12
11