view the column names for CSV file?

Solution 1:

head -n 1 file.csv

or

sed 1q file.csv

or

grep -m 1 '' file.csv

or

awk 'NR==1 {print; exit}' file.csv

Solution 2:

You can use csvtool to obtain column names. First install it from Ubuntu repository:

apt install csvtool

Then run it on the csv file:

csvtool head 1 file.csv

Output:

name1,name2,name3

If You need each column name in a separate line use tr command like this:

csvtool head 1 file.csv | tr -s ',' '\n'

name1
name2
name3