Thursday, November 27, 2003

How to compare 2 files and show the items that appear in both

Command: comm -12 file1 file2

comm output has 3 columns : colum 1 - items that only appear in file1 , column 2 - only in file2 , column 3 - items that appear in both files.

Extract a listing of email addresses you have sent email to from your maillog and stick it in a text file, making sure that the mail addresses listed are sorted from A to Z and are uniquely listed.

grep "status=sent" maillog | awk '{print $7}' | cut -d'<' -f 2 | cut -d'>' -f 1 | sort --field-separator="@" | uniq > emails_sent_to.txt

Note: the awk command means "print column 7". A space separating an item of text in a line is considered a column delimiter by Awk

GKrellM: Geek eye-candy, monitors, and more