As a result of the command variable assignment

1, the variable name = `ls` using reverse quotes

2, the variable name = $ (ls) with $ () enclosed, the recommended method

 

yao @ linux: ~ / shell $ PWD = $ (pwd)
yao @ linux: ~ / shell $ echo $ PWD
/ home / yao / shells

yao@linux:~/shells$ user=`whoami`
yao@linux:~/shells$ echo $user
yao

Example 1: by date package directory

yao@linux:~/shells$ tar zcf shells_$(date +%F).tar.gz .
yao@linux:~/shells$ ls shells_2019-10-20.tar.gz
shells_2019-10-20.tar.gz

 

Guess you like

Origin www.cnblogs.com/yaowensheng/p/11706801.html