Open many web pages at once via the Terminal

Jan 31, '05 09:16:00AM

Contributed by: maniabug

So you got a list of web pages in your email, and don't feel like pasting them all into a browser? Or clicking each of them, one by one? The list looks like this:

http://www.foo.com/bar.html
http://en.wikipedia.org/wiki/Diet_of_Worms
http://www.operationcitadel.net/404.php
Instead of clicking or pasting, copy them all to the clipboard, open a Terminal window, and enter this command:
pbpaste | xargs open
[robg adds: For those of you new to Unix, here's my attempt at explaining how this works (others may be clearer than I, so feel free to comment): pbpaste simply pastes the contents of the clipboard into the Terminal (try it with no arguments sometime when you have something on the clipboard). The pipe symbol (|) then passes the clipboard's contents to xargs. xargs takes input (in this case, the list of URLs) and passes them to the next command listed. In this case, that's open, which opens files, directories, and ... URLs. So the end result is that each URL is passed to the open command, which then opens them in your browser.]

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050128105811131