bash - Ignore empty fields -


given file

$ cat foo.txt ,,,,dog,,,,,111,,,,222,,,333,,,444,,, ,,,,cat,,,,,555,,,,666,,,777,,,888,,, ,,,,mouse,,,,,999,,,,122,,,133,,,144,,, 

i can print first field so

$ awk -f, '{print $5}' foo.txt dog cat mouse 

however ignore empty fields can call this

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

you can use this:

$ awk -f',+' '{print $2}' file dog cat mouse 

similarly, can use $3, $4 , $5 , on.. $1 cannot used in case because records begins delimiter.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -