Example 2: Open URLs
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-scriptsInside this folder create a file called open-urls.sh.
touch open-urls.shOpen this file in a text-editor
gedit open-urls.shIf you have Sublime-Text installed you can use
subl open-urls.shNow write the shebang for the script.
#!/bin/bashCreate 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 $URL2Now save the file and close the text-editor.
Use chmod to make this script an executable.
sudo chmod +x open-urls.shRun the script.
./open-urls.shNow Firefox should open up the two URLs in two separate windows.
Code
#!/bin/bashStore 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