Linux 命令实用技巧

掌握这些 Linux 命令技巧后,操作 Linux 命令将更快更便捷!
目前想到哪些文章编写哪些,因此会持续更新!

cd -

cd - 返回上一次所在目录。

1
2
3
4
5
6
7
8
9
# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~/Documents/blog [16:03:24] 
$ cd ~

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~ [16:03:30]
$ cd -
~/Documents/blog

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~/Documents/blog [16:03:34]
$

zsh 可以省略 cd 命令。

$_

创建目录并进入该目录,一般我们会这么写:

1
2
3
4
5
# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~/Documents/blog [16:11:05] C:1
$ mkdir -p ~/Downloads/aa/1/2/3

# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~/Documents/blog [16:11:20] C:1
$ cd ~/Downloads/aa/1/2/3

如果使用 $_ 符号,可以一条命令,且可以省略 cd 后面的长路径 ~/Downloads/aa/1/2/3

1
2
3
# ganzhixiong @ ganzhixiongdeMacBook-Pro-3 in ~/Downloads [16:14:52] 
$ mkdir -p ~/Downloads/aa/1/2/3 && echo $_
/Users/ganzhixiong/Downloads/aa/1/2/3

Linux 命令实用技巧

https://ganzhixiong.com/p/5c13f1aa/

Author

干志雄

Posted on

2021-09-12

Updated on

2021-09-12

Licensed under

Comments