I have a list of URLs in a text file, for example,


I wonder how to open them each in one tab in Firefox (or SeaMonkey), without the hassle of creating a new tab, copying into address bar and hitting return for each URL?

My OS is Ubuntu 10.10. Both command line and GUI solutions are welcome.


6 Answers 6


You can save the following to a HTML file:

<!doctype html>
<title>Open Windows</title>
function openWindow(){
    var x = document.getElementById('a').value.split('\n');
    for (var i = 0; i < x.length; i++)
        if (x[i].indexOf('.') > 0)
            if (x[i].indexOf('://') < 0)
html, body
    height : 99%;
    width  : 99%;

    height : 80%;
    width  : 90%;
<textarea id="a"></textarea>
<input type="button" value="Open Windows" onClick="openWindow()">
<input type="button" value="Clear" onClick="document.getElementById('a').value=''">

Now load the file in Firefox, copy the list of URLs in the textarea and click Open Windows.

  • 1
    Hah... I haven't thought 'bout that one! I usually do it with firefox `cat file.txt` (as WakiMiko wrote). Anyway using your way will work on all OS. :D
    – tftd
    Feb 2, 2012 at 16:39
  • 1
    Now this is what I call "for the win." +1 for platform independence. Would definitely accept this answer. Supported: SeaMonkey, FireFox, IE, Chrome, Safari, etc...Ubuntu, Windows, Mac, etc.
    – Matt Borja
    Jun 6, 2012 at 22:39
  • Technically chrome blocking as pop-ups. But since I need source and I'm running fiddler, you made my day. Thanks a done.
    – Jones
    Apr 8, 2013 at 15:12
  • This is perfect. Is there anyway to add a slight delay, lets say 5 seconds between opening each tab? Nov 30, 2016 at 17:16
  • @DomainsFeatured Sure. You could use setInterval to iterate over the domains and cancel it once all of them have been processed.
    – Dennis
    Nov 30, 2016 at 17:29

A simple

firefox $(cat file.txt)

should suffice. It will pass each link as an argument to the firefox command, as long as every link is separated by whitespace.

  • 1
    +1. Thanks! That works! I wonder if you happen to know how to do that in SeaMonkey? I tried seamonkey $(cat urls), but only the url in the first line is opened.
    – Tim
    Feb 2, 2012 at 17:03
  • 1
    if you're doing this over SSH to something running Xorg, you need to set the display to open firefox window in: env DISPLAY=:0 firefox $(cat file.txt)
    – zfogg
    May 31, 2020 at 21:17
  • cat is not needed, firefox $(< example-domains.txt) is more streamlined — see stackoverflow.com/questions/11710552/useless-use-of-cat and unix.meta.stackexchange.com/questions/1261/…
    – user198350
    Jun 16 at 8:35
  • If the --new-tab flag is added — firefox --new-tab $(< example-domains.txt) — Firefox only appears to open the first tab in the current window. See my answer for a potential solution (but works on my machine).
    – user198350
    Jun 16 at 8:38

On windows you can create a batch file (named say, multiurl.bat):

@echo off    
for /F "eol=c tokens=1" %%i in (%1) do "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" %%i

and then run multiurl.bat urls.txt from the command line and it will load the URLS in new tabs if FireFox is already open, or it will run it and then load the URLS.

  • You aren't required to create a .bat file to use the for command. Feb 2, 2012 at 16:25
  • 2
    This is not relevant - the users asks for a solution that will work on Linux machines!
    – tftd
    Feb 2, 2012 at 16:37
  • 1
    @TheDevil Come on, this answer took longer than three minutes to test and type. I suggest tfitzgerald keeps this answer up, there might be others interested. I sure won't delete my answer for OS X.
    – Daniel Beck
    Feb 2, 2012 at 17:20
  • @TheDevil Yes, he edited his question as I was writing my answer. Feb 3, 2012 at 1:47
  • 1
    @OliverSalzburg That is correct. But I don't think I said you are required to...but why would you want to type that whole line each time you wanted to do this? That is what scripts are for! Feb 3, 2012 at 1:48

On Mac OS X, save the following script as openurls.sh, run chmod +x openurls.sh in Terminal, and then type ./openurls.sh from the same directory.

#!/usr/bin/env bash

while read line ; do
    open -a Firefox "$line"
done < "/path/to/file-with-urls.txt"
  • +1. Thanks! Do you also know how to do that for SeaMonkey instead of Firefox?
    – Tim
    Feb 2, 2012 at 16:12
  • @Tim I don't have SeaMonkey to test it. Also, I'm afraid this script opens windows instead of tabs, sorry about that.
    – Daniel Beck
    Feb 2, 2012 at 16:16
  • 1
    This can easily be fixed with changing some settings in Firefox. Go to Edit->Preferences->Tabs and select "Open new window in new tab instead" :)
    – tftd
    Feb 2, 2012 at 16:41
  • @TheDevil Thanks! I guess it's obvious I only use FF for answering questions on SU.
    – Daniel Beck
    Feb 2, 2012 at 16:42
  • Is there a way to specify the Firefox profile? Nov 30, 2016 at 16:46

Open your text file in firefox as

  1. Select the whole link
  2. Right click on it
  3. Click on "Open Link in new tab"
  • 1
    Only opens one (ex. the first url from many selected)
    – Xen2050
    May 17, 2016 at 20:29

To expand on an existing Linux answer, personally I strongly prefer opening all pages in the same (existing, open) browser window. Unfortunately Firefox (command-line flags) appears not to accept all the input at once and I had to implement delay (sleep) between actions with xargs (source):

<example-domains.txt xargs -I "%" sh -c '{ firefox --new-tab "%"; sleep 0.25; }'

You may be able to use a significantly shorter delay than 0.25 seconds. You can try out the method with a file containing (about the reserved domains):

  • xargs 4.9.0, Mozilla Firefox 114.0 (documenting if the method turns out to be not entirely universal and compatible)
    – user198350
    Jun 16 at 8:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .