[How To]: Execute Multiple Commands in Terminal

Share it!!Share on Facebook3Share on Google+2Tweet about this on Twitter5Share on Reddit0Share on StumbleUpon0

Running multiple commands really helpful in many ways for installing packages, copying files, moving files, …. .Sometimes when you try to install a package output message show that you have install extra dependencies, this will be really annoying to install them one by one. with these commands will make it easily for you to write it once for all.

Execute the second command if the first command successful or execute the third command if the first and the second successful

sudo apt-get install pidgin && cd ~/Music && cd ~/Downloads

in this case if write all commands correctly the output should be opening “Download directory” after finishing the installation for “Pidgin” application.

AND logical gate.

Execute the second command if the first failed or execute the third command if the first and the second commands failed.

sudo apt-get install kats || cd ~/Musc || cd ~/Downloads

in this case i missed spelling kate application and wrote it “kats” instead of “kate”, also music directory, but last command wrote correctly so it will execute the last command.

OR logical gate.

Execute commands regardless these command are correct or not.

you will just need add semicolon “;”between them.

sudo apt-get install kate; cd ~/Musfdic; cd ~/Downloads

you can add as much as you want of commands.

Source

Share it!!Share on Facebook3Share on Google+2Tweet about this on Twitter5Share on Reddit0Share on StumbleUpon0
4 Comments

Add a Comment

Your email address will not be published. Required fields are marked *