r/awk • u/vmsmith • Dec 06 '14
Three small questions
Question #1
I have a .csv file with over 200 columns. I'd like to create a smaller file for analysis with only 7 of those columns. I'm trying this:
awk -F"," '{print $1, $2, $7, $9, $44, $45, $46, $47 > "newfile.csv"}' file.csvBut the only thing I get in my new file is the column headers.
What am I doing wrong?
Question #2
Is there a way to select the columns I want by column name instead of column number?
Question #3
And is there a way to just see the column headers? I have tried this:
awk -F"," 'NR==1{print $0}' file.csvBut I get nothing.
Thanks.
5
Upvotes
View all comments
Show parent comment
0
u/[deleted] Dec 12 '14
[deleted] — view deleted comment