How I would go about opening multiple URLs from a text file as different tabs in Firefox/Chrome? My text file is just a list of URLs, one per line:
http://www.url1.com
http://www.url2.com
http://www.url3.com
http://www.url4.com
How I would go about opening multiple URLs from a text file as different tabs in Firefox/Chrome? My text file is just a list of URLs, one per line:
http://www.url1.com
http://www.url2.com
http://www.url3.com
http://www.url4.com
Firefox uses the new-tab
command, so you could pass the URLs in the file to the browser like so:
while read line; do
firefox --new-tab "$line"
done < textfile.txt
With Chrome, the syntax is:
google-chrome "$line"
I think this may be a nice solution:
xargs -n1 firefox -new-tab < allmyURLs.txt
or:
xargs chromium-browser --new-tab < allmyURLs.txt
The -n1
is needed on Firefox 84 because you need one -new-tab
argument for every URL.
xargs -L1
on Firefox 84: https://superuser.com/questions/772153/how-to-open-multiple-urls-in-chrome-firefox-and-then-save-them-individually/1622388#1622388
– Ciro Santilli OurBigBook.com
Jan 31 '21 at 22:50
If there is only a number changing in the url, then you can change the number as given below. If they are different urls then you can use jasonwryan's solution.
google-chrome --new-tab http://www.url{1..4}.com
The above command will expand as below in new google chrome tabs:
http://www.url1.com http://www.url2.com http://www.url3.com http://www.url4.com
This solution is typically to load all pages where you would have to do next, next to go through the pages.
okay... so here was a wildly more efficient script for my use.
#!/bin/bash
#make sure an instance of firefox starts up first
firefox
#let it load
sleep 2
#open the links
cmd="firefox"
while read link; do
cmd+=" --new-tab ${link}"
done < ./source_of_links.txt
${cmd}
this works much faster as it executes only one firefox command. if you try to open a new link with firefox in a loop - you may run into a bottle neck like I did... with this above script - all the links always open at once.
On windows / cygwin... this worked for me:
#!/bin/bash -xe
browser="/cygdrive/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"
clients="fb aapl nflx "
for i in $clients
do
"$browser" --new-tab https://asite.com/dashboard/$i
done
alias google-chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
. Probably similar for Firefox. – David Winiecki Dec 11 '14 at 20:58xargs
was made for! :-) https://unix.stackexchange.com/a/139842/32558 It's even POSIX: https://pubs.opengroup.org/onlinepubs/009695399/utilities/xargs.html – Ciro Santilli OurBigBook.com Jan 31 '21 at 22:16