Tuesday, February 9, 2016

AWK: FS, RS, OFS, ORS

Testing FS (field separator), RS (record separator), OFS (output field separator), ORS (output record separator):

Command:

$ echo -n '"test,test",testtest,test,test' | awk 'BEGIN{FS=",";RS="\n";OFS="-";ORS="+"}{print $1, $2, $3, $4, $5, $6}'


Output:

"test-test"-testtest-test-test-+