I have some commands that take too long to execute so I need a bash script to execute them serially.
cd ~/my_file command 1 command 2 ... command n
This is on Ubuntu 18.04. How should I do it?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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 +x my-script.sh
And run it using
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.