Citation

Quotes are used to remove the interpretation of special characters (such as $ \n! and others) by the shell.

There are the following quotes:

Double quote

" "
Is placed between Double quote text that the values ​​of variables that contain spaces.

Quotes retain special meaning three characters:

$ - indicates the name of a variable, allowing the substitution of its value
\ - a placeholder
` ` - reverse apostrophe, citing command allows

Example



#/bin/bash

x=2
echo "The x value is $x" # prints the value of the variable x= 2
echo -ne "You will hear a bell\a"
echo "The date command shows:`date`"

Single quote

' '
Everything included in the single quote character is treated as a text string to interpret the apostrophe off all special characters are treated as regular characters.

Example

#/bin/bash

echo '$ USER' #do not print your login

Backquote

` `
command allows you to quote, very useful if you want to substitute the variable outcome of a command such as:

Example

#/bin/bash
x = `ls -la $ PWD`
echo $ x # shows the result of the command


Alternative record of who has the same effect like this:

#/bin/bash
echo $ (ls-la $ PWD)

Backslash

\
To appear $HOME, you can write it in quotes but you can also mask the first of his character, as shown in the example.

Example

echo "$HOME" # prints /home/me
echo \$HOME # and is the $HOME
echo '$HOME' # and the $HOME

Putting a backslash \ at the end of the line tells the shell that the line is continued on the next line (normally the next line is the next instruction). This eliminates the need to write long poems, which interfere with the convenient editing and viewing a file (not all editors support automatic wrapping).

Local documents

Llocal documents
This is the kind of redirect, which allows some content to treat the script as standard input.

Example:

#/bin/sh

cat << _EOF
This text will be
displayed on the screen
limiter is _EOF
_EOF

After running the script on the screen get everything that we entered into between _EOF. This method can be used to display more information on the screen without having to type echo in each line.

Important: The final stop needs to find himself in one line. Delimiter can be any expression, but most often used is "_EOF".