Extract common data out of multiple files

UNIX for Dummies Questions & Answers




Kindly Note - This is a Single User Post by Forum Member Scrutinizer Regarding:
Extract common data out of multiple files.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old 12-24-2012
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
If there is maximum of 1 entry per file:
Code:
awk '++A[$0]>=ARGC-1' file*

This would then be a bit more robust:
Code:
awk '{$1=$1} ++A[$0]>=ARGC-1' file*

But 1000 files is probably going to be too many for the command line length.

Otherwise try:
Code:
( 
  set -- file*
  for f
  do
    cat "$f"
  done | awk '{$1=$1} ++A[$0]>=c' c=$# 
)


Last edited by Scrutinizer; 12-24-2012 at 07:14 AM..
The Following User Says Thank You to Scrutinizer For This Useful Post:
dovah (11-15-2015)