i have a CSV file i want to get the columns name for each column
sample :
how can i do that with awk or sed or grep ??
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityi have a CSV file i want to get the columns name for each column
sample :
how can i do that with awk or sed or grep ??
head -n 1 file.csv
or
sed 1q file.csv
or
grep -m 1 '' file.csv
or
awk 'NR==1 {print; exit}' file.csv
print
is the default action you can shorten the awk
command to awk NR==1 file.csv
.
– dessert
Jun 24 '18 at 9:17
awk 'NR==1 {print; exit}'
does the exact same as awk NR==1
.
– dessert
Jun 24 '18 at 10:30
awk NR==1
, still awk will read your whole file's lines where those are not necessary to read. Also that can be only awk '{print; exit}'
– αғsнιη
Jun 24 '18 at 10:48