There are 2 ways to "chain" programs together. If you're attempting to chain them together so that the output from the first is passed to the second then you're looking to use what's called a pipe. The other method simply runs one program after another.
Here we're taking the output from the first command and passing it through a pipe, (
|) to a second command.
$ echo "output from 1" | grep 1
output from 1
The output is being displayed on the screen by the
commands in series example
Here we're running one command followed by another.
Put the above in a file called
mycmds.bash, make it executable, and run it:
$ chmod +x mycmds.bash
You can also make use of subshells if you like, to run a series of commands at the prompt, and capture their output to a file. This will run the commands in the same fashion as the shell script method above.
just running commands
$ (echo 1; echo 2; echo 3)
capturing their output
$ (echo 1; echo 2; echo 3) | grep 3
capturing their output to a file
$ (echo 1; echo 2; echo 3) | tee mycmds.log
$ cat mycmds.log