Special Characters

The wildcard and set operators are four examples of bash’s special characters - characters that have a specific meaning to bash. In this article  all special characters are listes, with a brief description of each one.

Character Description
< Redirect input
> Redirect output
( Start subshell
) End subshell
} Pipe
\ Quote (escape) the next character
& Execute command in background
{ Start command block
} End command block
~ Home directory
` Command substitution
; Command separator
# Comment
Strong quote
Weak quote
$ Variable expression
* String wildcard
? Single character wildcard

Input and output redirection should be familiar to you. Although we will discuss subshells later in this chapter, it is important to note that all the commands between ( and ) are executed in a subshell. Subshells inherit some of the environment variables, but not all of them. This behavior is different from commands in a block (blocks are delimited by { and }), which are executed in the current shell and thus retain all of the current environment. The command separator, ;, allows you to execute multiple bash commands on a single line. But more importantly, it is the POSIX-specified command terminator. Special Programming Techniques

The comment character, #, causes bash to ignore everything from the character to the end of the line. The difference between the strong quote and weak quote characters, ‘ and “, respectively, is that the strong quote forces bash to interpret all special characters literally; the weak quote only protects some of bash’s special characters from interpretation as special characters.

Posted on: 10/12/2009








0 Comments
If you want to leave a comment please Login or Register