特殊符号 $
符号 $ 可以用作变量前面的标识符,还可以和 !结合起来使用。
!$:表示上一次使用的路径
[root@evan-01 ~]# ls
11.txt 3.txt a.txt test test2.txt.bak testdir
1.txt anaconda-ks.cfg bb.txt test2 test3_soft.txt txtdir
2.txt anaconda-ks.cfg.bak ojbk.txt test2_heard.txt test3.txt.bak
[root@evan-01 ~]# cat 2.txt
123
456
123
456
abc
1
2
1
abc
[root@evan-01 ~]# ls -l !$
ls -l 2.txt
-rw-r--r--. 1 root root 30 Oct 21 10:22 2.txt
[root@evan-01 ~]#
特殊符号 ;
通常我们都是在一行中输入一个命令,然后按回车就运行了。如果想在一行中运行两个或两个以上的命令,需要在命令之间加符号 ; 。
[root@evan-01 ~]# ls 2.txt ; wc -l 2.txt ; cat 2.txt
2.txt
9 2.txt
123
456
123
456
abc
1
2
1
abc
[root@evan-01 ~]#
特殊符号 ~
符号 ~ 表示用户的家目录,root 用户的家目录是 /root ,普通用户则是 /home/username。
[root@evan-01 ~]# cd ~
[root@evan-01 ~]# pwd
/root
[root@evan-01 ~]#
[root@evan-01 ~]# su evan1