What's the difference between "and" in programming like MySQL and shells

phpMySQL uses backticks `to surround the column names and I just see people using backticks in shell scripts.

Is it the same if they use '?

+2


source to share


2 answers


The MySQL

backlinks can be used to enclose table and column names that are reserved words, such as:

SELECT  *
FROM    `table`

      

The single quotes simply denote a string constant:

SELECT  *
FROM    `table`
WHERE   `name` = 'test'

      

In wrappers, backticks allow the output of one command to be used as an argument to another command:

echo `date`

      



will execute date

and use its output as an argument for echo

.

Single quotes allow spaces, dollar signs, and backslashes within arguments:

echo '$HOSTNAME'

      

outputs the string $HOSTNAME

as it is,

echo $HOSTNAME
echo "$HOSTNAME"

      

both output the value of an environment variable HOSTNAME

.

+8


source


In the shell, a pair of back exits will be replaced by the output (stdout) of the command they enclose.



X=`expr 3 \* 2 + 4` # expr evaluate arithmatic expressions. man expr for details.
echo "$X"

      

0


source







All Articles