awk to count and print header row of file -
i using combination of head , awk count number of fields in header row of tab-delimited file. below seems close want print header names in file on newline. there better way start. thank :).
file
index chr start end ref alt awk current output
head -n 1 file | awk -f'\t' '{print nf " fields detected in file"}' 6 fields detected in file desired output
6 fields detected in file index chr start end ref alt
try -
$ awk ' {print nf " fields detected in file"} end {print}' f 6 fields detected in file index chr start end ref alt or
$ awk ' {print nf " fields detected in file"rs $0;exit}' f 6 fields detected in file index chr start end ref alt
Comments
Post a Comment