Executing Multiple Commands at Once
From either the command-line or from within shell scripts, it’s handy to know how to combine multiple commands into one single command. In this section, I’ll demonstrate three ways to do that which are:
- Running commands interactively
- Using command sequences
- Using the
find
utility
Running Commands Interactively
This is a form of shell-script programming, except that you’re just executing all commands from the command-line, instead of actually writing, saving, and executing a script. Here, you are creating a for loop – with each command of the loop on its own separate line – to perform a directory listing three times.
[donnie@fedora ~]$ for var in arg1 arg2 arg3
> do
> echo $var
> ls
> done
. . .
. . .
[donnie@fedora ~]$
At the end of each line, you’ll hit the Enter key. But, nothing will happen until you type the done
command on the final line. The...