Skip to content

To write a shell script to open following two URLs in Firefox in two separate windows.

https://www.e-yantra.org/
http://www.iitb.ac.in/

Steps:

Go inside the shell-scripts folder.

cd ~/workspace/shell-scripts

Inside this folder create a file called open-urls.sh.

touch open-urls.sh

Open this file in a text-editor

gedit open-urls.sh

If you have Sublime-Text installed you can use

subl open-urls.sh

Now write the shebang for the script.

#!/bin/bash

Create two variables to store the string two URLs.

URL1="https://www.e-yantra.org/"
URL2="http://www.iitb.ac.in/"

Pass the two URL variables as arguments to firefox command along with the flag to open the URLs in separate windows.

firefox -new-window $URL1 $URL2

Now save the file and close the text-editor.

Use chmod to make this script an executable.

sudo chmod +x open-urls.sh

Run the script.

./open-urls.sh

Now Firefox should open up the two URLs in two separate windows.

Code

#!/bin/bash

Store URLs in two variables

URL1="https://www.e-yantra.org/"
URL2="http://www.iitb.ac.in/"

Print some message

echo "** Opening $URL1 and $URL2 in Firefox **"

Use firefox to open the two URLs in separate windows

firefox -new-window $URL1 $URL2