Learn a bash script today and see that there is a: bin= ' dirname '
(dirname filename is the directory where the file is exported, and $ is the file name of the bash file, which is generally used in bash to enter the directory where the script is located)
I tried the cat $bin
The output is:.
Then I'm going to take the anti-quote "' Out: Bin=dirname"
Error after running cat $bin.
I looked online for some of Bash's single-quote ', double-quote ' and ' anti-quote ' differences.
Single quote ' and double quote ' "
Both are the problem of resolving a space in the middle of a variable.
In bash, "whitespace" is a very special character, such as the str=this is String defined in bash, which will cause an error, using single quotes "and double quotes" in order to avoid errors.
The single quote ', double quote ' "is the difference between a single quote ' ' that deprives all characters of a special meaning, and a single quote ' inside a simple character. The double quotation mark "" is an exception to the argument substitution ($) and command substitution (") in the double quotation mark" ".
Say n=3.
Echo ' $n '
The result is N3.
Change it to double quotes, echo "$n," and the result is 3.
Anti-Quote "'
Anti-quote ' is command substitution, command substitution means that the shell can execute the command in the ', and the output will be saved temporarily, and output in the appropriate place. Syntax: ' Command '
In the following example, the command execution results are saved in a variable:
#!/bin/bash
DATE=`date`
echo "Date is $DATE"
USERS=`who | wc -l`
echo "Logged in user are $USERS"
UP=`date ; uptime`
echo "Uptime is $UP"
Operation Result:
Date is Thu Jul 2 03:59:57 MST 2009
Logged in user are 1
Uptime is Thu Jul 2 03:59:57 MST 2009
03:59:57 up 20 days, 14:03, 1 user, load avg: 0.13, 0.07, 0.15
The difference between a Linux shell, a double-quote "", a single quote ", and an anti-quote"