[SOLVED] [BASH][AWK] filtering by column; value greater than 0
by czezz from LinuxQuestions.org on (#5QQ83)
Im trying to filter out every single record by column "Connection_time" that is greater than: 000000.
Here is my sample.out
Code:cat sample.out
|Date|Time|Type|MSISDN|Connection_time|Cost|
|26.06.2021|2040|Dane||8.01MB|0|
|26.06.2021|1701|Dane||9.67MB|0|
|26.06.2021|1639|Dane||0.2MB|0|
|26.06.2021|1339|Voice|xxxx|000135|0|
|26.06.2021|1239|Other||000000|0|
|26.06.2021|1120|||000000|1|
|26.06.2021|1120|Voice|xxxx|000138|0|
|26.06.2021|0622|Other||000000|0|
|26.06.2021|0000|Other||000000|0|
|25.06.2021|2203|Voice|xxxx|000016|0|
|25.06.2021|2103|Voice|xxxx|000056|0|
|25.06.2021|2038|Voice|xxxx|000102|0|
|25.06.2021|2016|Voice|xxxx|000038|0|
|25.06.2021|1909|SMS|xxxx|000000|0|
|25.06.2021|1849|SMS|xxxx|000000|0|
|25.06.2021|1843|SMS|xxxx|000000|0|To filter out all records equal 000000 works OK.
Code:$ cat sample.out | awk -F"|" '$6==000000'
|26.06.2021|1239|Other||000000|0|
|26.06.2021|1120|||000000|1|
|26.06.2021|0622|Other||000000|0|
|26.06.2021|0000|Other||000000|0|
|25.06.2021|1909|SMS|xxxx|000000|0|
|25.06.2021|1849|SMS|xxxx|000000|0|
|25.06.2021|1843|SMS|xxxx|000000|0|However, when I try to filter out records greater than 000000 I get the whole output of sample.out / the criteria is ignored.
It does not work probably because AWK does not know/recognize it is "integer".
Code:$ cat sample.out | awk -F"|" '$6>=000000'Question:
Is there any way to filter by column Connection_time greater than 000000?
(I know - it would be easier to import output to some DB)
Here is my sample.out
Code:cat sample.out
|Date|Time|Type|MSISDN|Connection_time|Cost|
|26.06.2021|2040|Dane||8.01MB|0|
|26.06.2021|1701|Dane||9.67MB|0|
|26.06.2021|1639|Dane||0.2MB|0|
|26.06.2021|1339|Voice|xxxx|000135|0|
|26.06.2021|1239|Other||000000|0|
|26.06.2021|1120|||000000|1|
|26.06.2021|1120|Voice|xxxx|000138|0|
|26.06.2021|0622|Other||000000|0|
|26.06.2021|0000|Other||000000|0|
|25.06.2021|2203|Voice|xxxx|000016|0|
|25.06.2021|2103|Voice|xxxx|000056|0|
|25.06.2021|2038|Voice|xxxx|000102|0|
|25.06.2021|2016|Voice|xxxx|000038|0|
|25.06.2021|1909|SMS|xxxx|000000|0|
|25.06.2021|1849|SMS|xxxx|000000|0|
|25.06.2021|1843|SMS|xxxx|000000|0|To filter out all records equal 000000 works OK.
Code:$ cat sample.out | awk -F"|" '$6==000000'
|26.06.2021|1239|Other||000000|0|
|26.06.2021|1120|||000000|1|
|26.06.2021|0622|Other||000000|0|
|26.06.2021|0000|Other||000000|0|
|25.06.2021|1909|SMS|xxxx|000000|0|
|25.06.2021|1849|SMS|xxxx|000000|0|
|25.06.2021|1843|SMS|xxxx|000000|0|However, when I try to filter out records greater than 000000 I get the whole output of sample.out / the criteria is ignored.
It does not work probably because AWK does not know/recognize it is "integer".
Code:$ cat sample.out | awk -F"|" '$6>=000000'Question:
Is there any way to filter by column Connection_time greater than 000000?
(I know - it would be easier to import output to some DB)