Hi All,
I have multiple (5+) text files with single columns and I would like to grep the common values across all the text files and parse it to a new file. All the values are numerical. Please let me know how to do it using awk.
Often easier to understand by providing data input examples and desired output.
And, include the commands you have tried so far.
Don't forget to use CodeTags around the data and commands.
File1
1
2
4
5
6
7
File2
1
2
5
9
6
10
File3
1
2
5
9
7
10
11
Desired output
1
2
5
There will be more than 3 files.
---------- Post updated at 09:55 AM ---------- Previous update was at 09:46 AM ----------
what I tried
perl -ane 'print"$F[1]\n" unless $seen{$F[1]}++' file1.txt file2.txt file3.txt > output
you can use
sort file1 file2 | uniq -d >> newfile
Franklin,
I apologise for not following code tags. Read the rules about them and will follow them. Thanks for correcting me again.
Jay
If there is no more than one occurrence of each value per file:
awk '++A[$1]==ARGC-1' file*
1 Like
Very slick.
Regards,
Alister