Shell Processing Order

  1. Split command line into tokens ( SPACE, TAB, ; ...)
  2. Check for key words ( if, while, for ...)
  3. Check for aliases ( alias dir='ls -l' )
  4. Tilde (~) expansion
  5. Variable substitution ( $varname )
  6. Command substitution ( $(command_name) )
  7. Arithmetic Evaluation ( $(( x = 2+3 )) )
  8. Split into tokens using the IFS normally this is white space
  9. Wilcard expansion ( * ? [] )
  10. Command lookup
    1. builtin commands
    2. functions defined by user
    3. executable programs on the system in its PATH
  11. Redirection ( < > .. )
  12. Run the actual command

Special Characters and Quoting

You can precede the a special character with a backslash (\) to escape its special meaning. There are three kinds of quotes available and all three are DIFFERENT.

Strong Quote

String quote will NOT perform any special interpration of the characters. You cannot have single quotes inside single quotes even if you precede them with a backslash

Weak Quote

Weak quote performs selected substitution. A strong quote inside a weak quote has no effect. You can include a double quote inside a double quote only if you PRECEDE it with a backslash (\). You also need to escape the dollar sign ($) inside double quotes, the (`) command subsitution and the (\) backslash itself.

Weak quote will evaluate steps 5-7 in the shell processing order:

Examples of quoting


   $ cd
   $ mkdir dir_qoutes
   $ cd dir_quotes
   $ touch file_one
   $ name=derek
   $ echo *
   $ echo $name
   $ echo $(ls)
   $ echo * $name $(ls)
   $ echo '* $name $(ls)'
   $ echo "* $name $(ls)"
   $ echo \* \$name \$\(ls\)