awk - Print out only the first column in a non-standard CSV file -


i have file delimited comma ",", rows have 1 column, , rows have multiple columns separated ",". example:

nm_001066 nm_015378,nm_018156 nm_001006624,nm_001006625,nm_006474,nm_198389 

as can see above, third line has 4 columns delimited ",", need first column in every line.

i tried use awk: cat filename.txt | awk '{print $1}', not work. looking this. thank you!

i guess you're looking this:

awk -f, '{print $1}' file.txt 

-f, tells awk use comma field separator.

in simple case, same thing simpler cut:

cut -f1 -d, file.txt 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -