Show me the email addresses in this file that aren't in this other file...

Peter Rukavina

I have two text files, each containing a list of email addresses.

The first file, invited.txt, has 82 email address of people who responded positively to my initial call for interest in the Crafting {:} a Life unconference back in February.

The second file, registered.txt, has 50 email addresses of people who’ve registered for the unconference.

I know that there are some people who responded to the initial call who haven’t registered, and I want to double-check with them to see if they’re planning to come (some of them likely thought that initial call for interest was registering).

How to get the list of email addresses in the first file that aren’t in the second file?

It turns out to be pretty easy from the Mac command line:

grep -i -v -f registered.txt invited.txt

The grep command is used to search inside files for things.

  • The -i flag says “ignore the case of the letters”. This way peter@rukavina.net and Peter@Rukavina.net will appear to be the same, which is what we want.
  • The -v flags kind of turns grep on its head, so that rather than searching for lines that match, we tell it to search for lines that don’t match.
  • The -f registered.txt says “take the lines from this file as the what you’re looking for,” except in this case, because of the -v, it’s the what we’re not looking for.
  • The invited.txt is the file we want to search.

Put that all together and what you get is “show me every email address in invited.txt that doesn’t appear in registered.txt.”

Or, in other words, “tell me who I invited who hasn’t registered.”

Comments

Add new comment

Plain text

  • Allowed HTML tags: <b> <i> <em> <strong> <blockquote> <code> <ul> <ol> <li>
  • Lines and paragraphs break automatically.

About This Blog

Photo of Peter RukavinaI am . I am a writer, letterpress printer, and a curious person.

To learn more about me, read my /nowlook at my bio, listen to audio I’ve posted, read presentations and speeches I’ve written, or get in touch (peter@rukavina.net is the quickest way). 

You can subscribe to an RSS feed of posts, an RSS feed of comments, or a podcast RSS feed that just contains audio posts. You can also receive a daily digests of posts by email.

Search