Engine of a Mini Seven racing Mini
Photo: Copyright © 2009 Eelke Blok

Open a bunch of URLs from the clipboard in a browser on the Mac

Just now I had a bunch of URLs in a spreadsheet I wanted to quickly open. This time, it wasn't too quick, because I went down the rabbit hole of coming up with a solution (and making a blog post about it). Next time though....


  1. Copy your URLs into the clipboard (⌘C or Edit > Copy)
  2. Open a terminal
  3. Type:
    pbpaste|tr '\n' '\0'|xargs -0 -I{} open /Applications/Safari.app {} &

Quick rundown:

  • pbpaste is a command that simply outputs your current clipboard entry. You can pipe it anywhere you like. (Incidentally, a useful counterparts is pbcopy; you can pipe the output of any other command into it and it ends up in your clipboard, ready for pasting anywhere.)
  • tr converts newlines to nulls
  • xargs is the center of this whole thing. It feeds the individual lines to a command of our choice, in this case the open command, which we tell to use Safari (you could just as easily substitute your favourite browser, assuming it accepts a URL from the command line this way).


Add new comment