awk csv: print only lines where value in column 6 is greater than 1 -


i have 30 000+ line csv file , not need of it. comes supplier , want lines have value greater 1 lines 0 in 6th column shows quantity of 1 or more want print.

so noticing awk command weird data , tells me because of leading space in front of 0 in 6th column

awk '{ print $6 }' 2.1 link lan sata , 2u sata 1u ... goes on forever 

is there way filter out useless lines!

here attempt this

awk -f '$6 <= 1 {print $0}'  

here few lines

100005,pc-q08a,lian-li case pc-q08a mini tower 1/0/6 fan aluminum usb3.0 silver mini-itx retail,lian-li,cs, 0,145.98,7.92,ea,lb,csb,active,840353002388

100006,pc-q08b,lian-li case pc-q08b mini tower 1/0/6 fan aluminum usb3.0 black mini-itx retail,lian-li,cs, 0,127.28,7.92,ea,lb,csb,active,840353002395

100011,eah5450silent/di/1gd3(lp),asus video card ati radeon hd 5450 1gb ddr3 64bit low profile silent pci-express 2.1 dvi-i/hdmi/hdcp retail,asus tek,vc, 64,43.93,0.90,ea,lb,v1g,active,610839367436

100012,e783686,elotouch lcd 19inch 1919l e783686 intellitouch vga 1000:1 5m dark gray retail,elo touchsystems,mn, 0,748.84,21.50,ea,lb,ml9,active,na

the 3rd line has quantity 64 , line want; rest not. note 6th field in 3rd line 64.

it looks me left out "," argument -f, , have comparison backwards. (and it's not incorrect, don't need {print $0} since that's default action.)

$ cat file.txt 100005,pc-q08a,lian-li case pc-q08a mini tower 1/0/6 fan aluminum usb3.0 silver mini-itx retail,lian-li,cs, 0,145.98,7.92,ea,lb,csb,active,840353002388 100006,pc-q08b,lian-li case pc-q08b mini tower 1/0/6 fan aluminum usb3.0 black mini-itx retail,lian-li,cs, 0,127.28,7.92,ea,lb,csb,active,840353002395 100011,eah5450silent/di/1gd3(lp),asus video card ati radeon hd 5450 1gb ddr3 64bit low profile silent pci-express 2.1 dvi-i/hdmi/hdcp retail,asus tek,vc, 64,43.93,0.90,ea,lb,v1g,active,610839367436 100012,e783686,elotouch lcd 19inch 1919l e783686 intellitouch vga 1000:1 5m dark gray retail,elo touchsystems,mn, 0,748.84,21.50,ea,lb,ml9,active,na194170,46.9,42.2   $ awk -f, '$6 >= 1' file.txt 100011,eah5450silent/di/1gd3(lp),asus video card ati radeon hd 5450 1gb ddr3 64bit low profile silent pci-express 2.1 dvi-i/hdmi/hdcp retail,asus tek,vc, 64,43.93,0.90,ea,lb,v1g,active,610839367436 

with respect weird data you're seeing 6th field, again, missing field separator argument:

$ awk -f, '{ print $6 }' file.txt 0 0 64 0 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -