page

Jun 8, 2020

print range of columns


input:
column1,column2,column3,column4,column5,column6,column7,column8

output:

column2,column3,column4,column5,column6,column7

Answer

cut -d, -f2-7 <input-file>

or

$ awk -v b=2 -v e=7 'BEGIN{FS=OFS=","} {for (i=b;i<=e;i++) printf "%s%s", $i, (i<e ? OFS : ORS)}' file

b=beginning field number, e=end field number.

No comments:

Post a Comment