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.


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.

  • 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 '12 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 '12 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 '13 at 15:12
  • This is perfect. Is there anyway to add a slight delay, lets say 5 seconds between opening each tab? – DomainsFeatured Nov 30 '16 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 '16 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. 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 '12 at 17:03
  • 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 '20 at 21:17

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. – Der Hochstapler Feb 2 '12 at 16:25
  • 2
    This is not relevant - the users asks for a solution that will work on Linux machines! – tftd Feb 2 '12 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 '12 at 17:20
  • @TheDevil Yes, he edited his question as I was writing my answer. – tfitzgerald Feb 3 '12 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! – tfitzgerald Feb 3 '12 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 '12 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 '12 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 '12 at 16:41
  • @TheDevil Thanks! I guess it's obvious I only use FF for answering questions on SU. – Daniel Beck Feb 2 '12 at 16:42
  • Is there a way to specify the Firefox profile? – DomainsFeatured Nov 30 '16 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 '16 at 20:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.