Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Open many web pages at once via the Terminal UNIX
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.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,890 views]  

Open many web pages at once via the Terminal | 10 comments | Create New Account
Click here to return to the 'Open many web pages at once via the Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open many web pages at once via the Terminal
Authored by: swimboy on Jan 31, '05 11:17:03AM

An even easier way to do this is to just use:

open `pbpaste`

The backticks (shift-tilde) causes the shell to evaluate the contents before executing the rest of the command.



[ Reply to This | # ]
Open many web pages at once via the Terminal
Authored by: d1taylor on Jan 31, '05 12:29:17PM

Or you could use the "normalized standard notation" rather than backticks:

open $(pbpaste)

:-)



[ Reply to This | # ]
Open many web pages at once via the Terminal
Authored by: oink on Jan 31, '05 07:39:24PM

open $(pbpaste) is interesting and I want to know more.

It doesn't seem to work for me in tcsh, returns "tcsh: Illegal variable name."...

---
blurred visionary



[ Reply to This | # ]
Open many web pages at once via the Terminal
Authored by: kholburn on Feb 01, '05 06:42:58AM

Yeah, it doesn't work in tcsh only bash. (I'm not sure about zsh: I don't use it.)



[ Reply to This | # ]
xargs is better than `...` or $(...)
Authored by: alys on Feb 01, '05 05:41:53PM
It's easier to use open `pbpaste` but it's not as reliable. Using backticks (or $(...) in bash) will fail if you have too many arguments (in this case, too many URLs). I'm not sure what "too many" is; it is a reasonably large limit though, so in practice `...` will generally work. However, xargs will always work - it knows how to handle very large numbers of arguments. It's worth letting yourself get familiar with xargs.

[ Reply to This | # ]
Open many web pages at once via the Terminal
Authored by: StarvArt on Jan 31, '05 02:49:38PM
FYI, the open command will also do this with "mailto:" URLs as well (just not plain e-mail addresses).

[ Reply to This | # ]
Open many web pages at once via the Terminal
Authored by: punkass on Jan 31, '05 07:46:45PM

Just to clarify Rob's description, xargs actually takes the three line block of text and splits it into three seperate arguments (as opposed to one big one). Type

man xargs

at the prompt to learn more about how xargs works...



[ Reply to This | # ]
Open many web pages at once via the Terminal
Authored by: peragrin on Feb 01, '05 08:37:13AM

There is an easier way at least for Firefox users.

You can highlight a URL inside firefox(mozilla too) and drag it to the tab bar. Try it. Select and drag the link below to either blank space on the tab bar or to an exsisting tab.

www.macsxhints.com

you don't need to select the HTTP but you can. any url that firefox can open it will do so, ftp, mailto, etc.

As for opening multiple websites from the terminal, why? other than cool? if you have a list of sites in a browser it's far easier to open them in the browser. If it's a text document, you can select copy and drag without ever taking your hand off of the mouse.

Of coure learning how to do cool things from the terminal is always useful. Say opening a bunch of websites when you first start up in the morning.(people actually turn their machines off???)

---
I thought once I was found but it was only a dream



[ Reply to This | # ]
Why use the terminal? Easier for opening many URLs.
Authored by: alys on Feb 01, '05 05:47:30PM

Opening multiple URLs in the terminal is far easier than doing it manually in a browser if you have many of them. After about half a dozen, dragging URLs in Firefox becomes tedious.



[ Reply to This | # ]
Open many web pages at once via the Terminal
Authored by: hschickel on Feb 01, '05 08:17:38PM

Why?

Browser crash (Safari for instance).
30 tabs open...

:(

Restart browser.
Copy history.
pbpaste | xargs open
Off to the races.

:)

Hugh



[ Reply to This | # ]