You probably want to write a bash script.
You start by adding a line that tells your system “Hey, this is a bash script”. This way, your system knows what interpreter to use. For bash, this is typically #!/bin/bash
.
Typically, for a backup script, you want commands to run in a specific order and fail if a previous command fails. The way to do this is to use &&
The way to do this is to use &&
.
So command1 && command2
would run command2
only if command1
ran.
In other cases, you want to stream the output of a command into another command, in which case you use pipes.
If it’s an interactive application, you can pair this up with expect. Otherwise, it’s good practice to use variables.
Bash is a lot more powerful than this though — it’s got things like conditionals and loops you can abuse to make your life a lot easier. It’s also a handy ‘glue’ for tying together many simple text applications.