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

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -