[root@dyw219 ~]# cat /etc/profile LOGNAME=$USER MAIL="/var/spool/mail/$USER"
$
,變數用大括號括起來,變數沒接其他「英文字元或數字」時,大括號可以省略。下面變數 variable 沒設定,變數 PATH 為環境變數。
[root@dyw219 ~]# echo ${variable} [root@dyw219 ~]# echo $variable [root@dyw219 ~]# echo ${PATH} /sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin [root@dyw219 ~]# echo $PATH /sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin
[dywang@dyw219 ~]$ linuxpro=\ /home/dywang/Documents/latex/cjk-tex/linuxprogram/ [dywang@dyw219 ~]$ cd linuxpro bash: cd: linuxpro: No such file or directory [dywang@dyw219 ~]$ cd $linuxpro [dywang@dyw219 linuxprogram]$ pwd /home/dywang/Documents/latex/cjk-tex/linuxprogram