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?
01 Answer
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.
2