Bash script to execute multiple Unix commands

giakou4

I have some commands that take too long to execute so I need a bash script to execute them serially.

The commands:

cd ~/my_file 
command 1 
command 2
...
command n 

This is on Ubuntu 18.04. How should I do it?

AlexOnLinux

Create a script using nano my-script.sh. Add shebang and the commands or path to commands.

#!/bin/bash
/path/to/command/1
/path/to/command/2
/path/to/command/3

Make it executable using chmod

chmod +x my-script.sh

And run it using

./my-script.sh

Or as a one line command in bash:

command1 && command2 && command3 && commandN

This would execute the commands only if the previous command was executed successfully.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Execute gcloud commands in a bash script

From Dev

Bash script to spawn and execute commands

From Dev

execute multiple commands on console through unix shell

From Dev

Execute multiple unix commands from SAS

From Dev

Cannot execute shell commands in bash script

From Dev

How to execute git commands from bash script?

From Dev

bash script execute commands after ssh

From Dev

Bash script to read from a file and execute commands

From Dev

Bash script to read from a file and execute commands

From Dev

How to execute the following commands in a bash script?

From Dev

Execute multiple sage commands from php script

From Dev

How to execute multiple CLI commands in a python script?

From Dev

How to execute multiple CLI commands in a python script?

From Dev

How to execute multiple commands in Bash, some in the background

From Dev

Execute multiple commands in a terminal window from bash

From Dev

How to execute sudo commands with Expect & send commands in bash script?

From Dev

bash script for executing commands on multiple server

From Dev

Passing inputs to multiple commands in bash script

From Dev

php calling bash script with multiple commands issue

From Dev

php calling bash script with multiple commands issue

From Dev

Run multiple commands passed as an argument to a bash script

From Dev

execute bash script asynchronously multiple times?

From Dev

Bash Script execute commands from a file but if cancel on to jump on next one

From Dev

Bash script: How to execute commands consecutively without waiting for the previous one?

From Dev

Shell out into zsh and execute commands from bash script

From Dev

How to execute commands in docker container as part of bash shell script

From Dev

Bash script: How to execute commands consecutively without waiting for the previous one?

From Dev

How to execute shell commands in a loop from within a bash script?

From Dev

Bash script does not execute commands until after delay

Related Related

  1. 1

    Execute gcloud commands in a bash script

  2. 2

    Bash script to spawn and execute commands

  3. 3

    execute multiple commands on console through unix shell

  4. 4

    Execute multiple unix commands from SAS

  5. 5

    Cannot execute shell commands in bash script

  6. 6

    How to execute git commands from bash script?

  7. 7

    bash script execute commands after ssh

  8. 8

    Bash script to read from a file and execute commands

  9. 9

    Bash script to read from a file and execute commands

  10. 10

    How to execute the following commands in a bash script?

  11. 11

    Execute multiple sage commands from php script

  12. 12

    How to execute multiple CLI commands in a python script?

  13. 13

    How to execute multiple CLI commands in a python script?

  14. 14

    How to execute multiple commands in Bash, some in the background

  15. 15

    Execute multiple commands in a terminal window from bash

  16. 16

    How to execute sudo commands with Expect & send commands in bash script?

  17. 17

    bash script for executing commands on multiple server

  18. 18

    Passing inputs to multiple commands in bash script

  19. 19

    php calling bash script with multiple commands issue

  20. 20

    php calling bash script with multiple commands issue

  21. 21

    Run multiple commands passed as an argument to a bash script

  22. 22

    execute bash script asynchronously multiple times?

  23. 23

    Bash Script execute commands from a file but if cancel on to jump on next one

  24. 24

    Bash script: How to execute commands consecutively without waiting for the previous one?

  25. 25

    Shell out into zsh and execute commands from bash script

  26. 26

    How to execute commands in docker container as part of bash shell script

  27. 27

    Bash script: How to execute commands consecutively without waiting for the previous one?

  28. 28

    How to execute shell commands in a loop from within a bash script?

  29. 29

    Bash script does not execute commands until after delay

HotTag

Archive