2017年2月3日金曜日

Edit lines by AWK - line number, field number, gsub() and sub()


0. skip line number 9.
1. omit data after "-" in 2nd field.
2. delete first character in 1st field.
3. replace all 0x80 with "@"
3. print line number, the second last and last field.


cat t  | nkf | awk  '{if(NR != 9){sub("-.*","",$2); sub("^.","",$1);gsub("\x80","="); print NR," x ",$(NF-1)," x ",$NF;}}'

# gsub("[\x80\xe3]","<any character sequence>") 

0 件のコメント: