Using special characters in commands
An overview of special characters in commands, their meaning and examples.
The Vyatta FusionCLI management interface is based on the GNU Bash shell. When entering a command at the command prompt, keep in mind that some characters have special meaning to the shell. For example, one such special character is the space character, which denotes the end of a token in a command, as shown below.
prompt> show interfaces dataplane
In this example, the space characters separate the command line into three components: show, interfaces, and dataplane.
If you want to enter a string of characters that includes a literal character understood by the shell as a special character, you must enclose the character in double quotation marks (“). For example, if you want to enter a character string that includes a space, you must enclose the string in double quotation marks, as shown below.
vyatta@vyatta# set security firewall name TEST description "external inbound"
In this example, the space within the character string external inbound is within quotation marks and, therefore, loses its special meaning as a token separator.
Another example of a special character is the “pipe” character, also called the vertical bar (|), which separates two commands and means that the output of the command to the left of the pipe should be processed by using the command to the right of the pipe, as shown in the following example.
vyatta@vyatta# show interfaces | match dp
In this example, the pipe character tells the shell to run the show interfaces command and then process the output by using the match dp command; as a result, only lines that contain the dp character string are displayed. As for the space character, if you want a literal vertical bar in a command component, you must enclose it in double quotation marks.
In addition to the space and vertical bar, the following characters have special meaning for the shell.
- ampersand (&)
- semicolon (;)
- comma (,)
- left parenthesis (()
- right parenthesis ())
- left angle bracket (<)
- right angle bracket (>)
- backslash (\)
- pound sign (#)
In general, if you are unsure which characters are special, a good rule of thumb is to enclose anything that is not alphanumeric within double quotation marks.
Note that within a quotation-enclosed string, you can include a literal quotation mark by preceding it with a backslash, as shown in the following example.
"some \"quotes\" within quotes"
Of course, the rules become more complex if you want a literal backslash (\). As a general rule, try to avoid using quotation marks or backslashes as literal configuration values.