[Solved] Extract records based on a repeated column value

Hi guys,

I need help in making a command to find some data.

I have multiple files in which multiple records are present.. Each record is separated with a carriage return and in each record there are multiple fields with each field separated by "|"

what i want is that I want to extract all those records for which field number 9 is same...

The files are normal text files.

---------- Post updated at 01:19 AM ---------- Previous update was at 12:32 AM ----------

found it .. anyways...for anyone's reference.

ls | grep records |xargs cat | awk -F "|" '{print $9}'|sort|uniq -c|awk '{if ($1!=1) print $0}'|more
1 Like

try this..

 
awk -F\| '{a[$9]++;}END{for(i in a){if(a>1){print i}}}' *records*