Currently I have a script.sh file with the following content.

#!/bin/bash
wget -q http://exemple.com/page1.php;
wget -q http://exemple.com/page2.php;
wget -q http://exemple.com/page3.php;

I want to execute the commands one by one, when the previous finishes. Am I doing it in the right way? I've never worked with Linux before and tried to search for it but found no solutions.

Best Answer


Yes, you're doing it the right way. Shell scripts will run each command sequentially waiting for the first to finish before the next to start You can either join commands with ; or have them on separate lines.

command1; command2

or

command1
command2

There is no need for ; if the commands are on separate lines. You can also choose to run the second command only if the first exited successfully. To do so, join them with && .

command1 && command2

or

command1 &&
command2

For more information on the various control operators available to you, see here.