'Compare to Columns and write match to File [closed]
first off, i have two .csv files.
The first looks likes this:
email;md5
[email protected];a18bf786efb76a3d56ee69a3b343952a
[email protected];ed53e691ee322e24d8cc843fff68ebc6
[email protected];c1a2cfbf08a049a874271aecbf0dbf77
The second .csv looks likes this:
md5
ed53e691ee322e24d8cc843fff68ebc6
e197b72a853f375ae6a2bff84a90d88b
a9654d30d08b2e03666b5e41a2179f3b
what i want to do is, compare the md5 columns and write the email of the matching md5 string in a file.
The Export should look like this, cause the md5 hashes of file 1 and 2 matched, the result is the clear E-Mail Adress.
Thanks and regards!
Solution 1:[1]
grep -f md5 email | grep -v 'email;md5' | cut -d';' -f1
Will match all the substrings found in email that accure in md5.
Since the first lines will match, we can use another grep to prevent matching on email;md5
Then using cut we can split the csv (-d';') and only show the fist column (f1)
Output:
[email protected]
To write the output to a file, use:
grep -f md5 email | grep -v 'email;md5' | cut -d';' -f1 > output.txt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
