Search Results

Search: Posts Made By: Mrinal Mondal
1,531
Posted By Scrutinizer
To get unique results you could just run...
To get unique results you could just run everything throught sort -u:
grep -xFf file1 file2 | sort -u
or
awk 'NR==FNR{A[$1]; next}$1 in A' file1 file2 | sort -u



--
Alternatively, one...
1,531
Posted By Vikram_Tanwar12
You can also try like this 1st sort both...
You can also try like this

1st sort both the files

sort filename1 -o filename1
sort filename2 -o filename2

then try

comm -12 filename1 filename2
1,531
Posted By Scrutinizer
If I run both scripts on your sample: $...
If I run both scripts on your sample:


$ cat file1
Milestone1
Milestone2
Milestone3
Milestone4
Milestone5
Milestone6
$ cat file2
Milestone1
Milestone12
Milestone13
Milestone14...
1,531
Posted By Scrutinizer
You would need to redirect the output: grep...
You would need to redirect the output:
grep -xFf file1 file2 > file3

An alternative would be:
awk 'NR==FNR{A[$1]; next}$1 in A' file1 file2 > file3
1,531
Posted By Scrutinizer
Hi, try: grep -xFf file1 file2
Hi, try:
grep -xFf file1 file2
Showing results 1 to 5 of 5

 

Featured Tech Videos

All times are GMT -4. The time now is 09:49 AM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy