Terminal for Post Production - Syntax pt. 1 / MAN Pages


The most common commands used in Terminal follow a similar structure - here's an example:

rsync -av --progress /Volumes/DISK1/ /Volumes/DISK2/

Command - In this case rsync is the command in use.  Generally, commands are going to be the first thing entered on a line.  Bash comes with a lot of preinstalled commands without any additional configuration.  If I ever write about a tool in Terminal that isn't stock within Bash, I'll walk you through how to install it.  The command is then followed by a list of...

Options - Most commands will be followed by one or more options.  In this case, both -av and --progress are both sets of options.  Many options have both an abbreviated an a full version, such as -v and -verbose.  Several of these abbreviated options can be strung together at once.  For the command above, a and v stand for "archive" and "verbose."

Additional Arguments - After options, this input will depend on the command.  In the command above, the two directories listed indicate a source and destination.  Depending on the command however, these could be anything from directories to I/O redirections... we'll get into that!

A note on Whitespace - All arguments passed into a command in Bash are separated by a space.  Different languages deal with 'whitespace' differently.  Bash separates elements based on whitespace.  In the above example, -av--progress would generate an error, while -av --progress will be interpreted correctly.  To include whitespace intended to be interpreted as spaces, it's usually necessary to "escape" them - an identifier that tells Bash that a space is not intended to be interpreted as a separator.  In Bash we use the "\" character to escape whitespace.  For instance, the OS X Sierra would become:

OS\ X\ Sierra

There are quite a few exceptions to this rule, but we'll cover that in future posts.

Man Pages

Many commands in BASH come with their own manual pages.  These are very easy to access in Terminal - just type:

man <command_name>

These pages can be a little dense and difficult to understand until you've had a little more experience in Terminal, but they're a great reference for options as I mentioned above.  Many commands have many dozens of options (or even more).  As I mentioned earlier, stringing these options together is the first way in which you can start customizing commands and workflows to your needs.

In the next post, we'll start diving into our first commands.  I'll hold off on part 2 of this post until we're a little further along and we have some commands to use.

Return to Terminal for Post Production Index