bash - Either grep or AWK are ereasing the content of processed stream -


lets have file this:

asi bek bkg coe 0.00112000003 0.00003000000 -0.00001000000 0.00000000000 0.00170999998 -0.00009000000 -0.00008000000 0.00052000000 0.00089000002 -0.00003000000 -0.00028000001 0.00068000000 0.00031000000 0.00003000000 -0.00026000000 0.00057999999 0.00239000004 -0.00003000000 0.00004000000 0.00076999998 0.00000000000 0.00002000000 -0.00039000000 0.00050000002 0.00401999988 -0.00014000000 -0.00029000000 0.00046000001 0.00179999997 -0.00011000000 -0.00025000001 0.00044000000 0.00025000001 -0.00008000000 0.00004000000 0.00063000002 

(obviously larger, longer records - sample quite enough understand structure)

i want use digit-starting records (omit title). grep ^[0-9]. ! output nothing. because need use file in general columns use awk. , here next odd thing. when tried cat file | grep ^[0-9] | awk '{ print }' gaves me nothing. when set explicit column number in awk (like awk '{ print $1,$2...<and_so_on>}' works. i'd avoid using explicit column numbers since don't understand wrong grep , not beautiful solution.

thanks in advance help. hope such silly mistake made me.

it can dangerous not use quoting shell. shells such csh won't think unless quote pattern ^[0-9]. should use single quotes here ensure nothing interpreted:

$ cat file | grep '^[0-9]' | awk '{print $0}' 0.00112000003 0.00003000000 -0.00001000000 0.00000000000 0.00170999998 -0.00009000000 -0.00008000000 0.00052000000 0.00089000002 -0.00003000000 -0.00028000001 0.00068000000 0.00031000000 0.00003000000 -0.00026000000 0.00057999999 0.00239000004 -0.00003000000 0.00004000000 0.00076999998 0.00000000000 0.00002000000 -0.00039000000 0.00050000002 0.00401999988 -0.00014000000 -0.00029000000 0.00046000001 0.00179999997 -0.00011000000 -0.00025000001 0.00044000000 0.00025000001 -0.00008000000 0.00004000000 0.00063000002 

the cat , grep redundant here if going use awk. awk can patterning matching , read files itself:

$ awk '/^[0-9]/{print $0}' file 

the default block in awk {print $0} can drop that:

$ awk '/^[0-9]/' file 

as want skip on first line in file better solution be:

$ awk 'nr>1' file 

failing hidden character issues such line endings. try dos2unix file , see if trick or inspect file hex editor.


Comments

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

java - What is the equivalent of @Value in CDI world? -