I have a data set that has 1127 columns, I only need to know the header without listing the data itself in each column.
For example, data as
name age m 33 A 26
I need a code in UNIX that will give me the header, which in this case is: name, age.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
head -n 1 filename # OR cat filename | head -n 1
sed 1q filename # OR sed -n 1p filename # OR cat filename | sed 1q
awk NR==1 filename # OR cat filename | awk 'NR==1'
ex -sc '1p|q' filename
more -n2 -pq filename # OR cat filename | more -n2 -pq
In all of the above commands,
cat filename | is intended as a stand-in for any command that produces textual output, showing how to use these tools in a pipeline.
All commands use only features listed in POSIX Specifications.