using awk to parse csv and exclude field range
I have a large text file that is comma delimited.
it has 260 fields it is formatted very basically field1,field2,field3,...field260 There are no double quotes around any text or anything oddball. I want to print to a new file excluding field6-field239 This is what I've tried but it's not excluding the fields http://pastebin.com/k5BNwnNS anybody offer some help? Thanks. |
Nevermind...
gawk -F"," -v f=6 -v t=239 '{ for (i=1; i<=260;i++) if( i>=f && i<=t) continue; else printf("%s%s", $i,(i!=0) ? OFS : ORS) }' tx000452010.txt solved. facepalm |
Just as an alternative
Code:
cut -d',' -f1-5,240-260 filename :) |
Alternate awk:
Code:
awk 'BEGIN{ORS=RS=","}NR < 6 || NR > 239' file |
All times are GMT -5. The time now is 05:22 AM. |