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....
Steps:
- Copy your URLs into the clipboard (⌘C or Edit > Copy)
- Open a terminal
- 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).
Sources:
- How to pass each line of a text file as an argument to a command? (Stack Overflow)
- Launch an app on OS X with command line (Stack Overflow)
Add new comment
Category