find similar lines according to delimited column's value
Hi all,
kinda new here and totaly newbe in linux commands. I have text file in which each line data is seperate by ';' delimiter. I like to find how many rows in the file, contain some specific column's value (i.e. $6 = 1234) Thank you all in advance. |
you can use awk. Delimiter can be given as -F\; You will need to count lines containing that given string:
$6 == 1234 {a++} and finally you will need to print the result: END { print a } are you familiar with awk? |
Hi pan64,
Thanks for your quick response. Unfortunately, I'm not familiar with awk. Any chance you can give me a little hint? Thanks again. |
I gave you hints, a lot. You just need to copy those lines into a single file:
awk -F\; '$6 == 1234 {a++} END { print a }' |
Thank a lot Pan64.
of course it works :) |
One more thing, if I may,
what should I do in order to count distinct rows? I mean, all rows which share the same value for coulmn 6 (i.e S6==1234) will be counted as 1 row. Thanks again. |
glad to help you
Happy with solution ... mark as [SOLVED] If you really want to say thanks just click on Yes |
$6 == 1234 {a[$0]++}
END { print length(a) } |
I'm apologize, I didn't explain what I want correctly,
I want to count distinct row in the file. distinct rows are rows which has difderent value for column 6 ($S6). Sorry for the nag. Thanks again for you kind help and patient. oran |
awk -F\; '{a[$6]++} END { print length(a) }'
will do that. Also you can play with the array a to print the values found. |
Thanks a lot man.
Appreciate your help. |
All times are GMT -5. The time now is 11:32 AM. |