命令行之浏览文件系统
查看文件系统, 主要有几个需求:
- 我在哪儿
- 我要去哪儿
- 当前目录下有什么
1. 我在哪儿:
1 | pwd |
2. 我要去哪儿:
两种方式去, 一种是绝对路径, 一种是相对路径.
1 | cd /home/grady/workspace # 绝对路径去 |
..
是一个特殊的目录, 表示当前目录的上一级目录.
.
也是一个特殊目录, 表示当前目录.
3. 当前路径下有什么
简单列出
1
2
3ls #单纯的列出有哪些文件
➜ ls
a.mp4 c d dir1 e m.c s.js test.pdf类似于Finder的这个视图:
详细列出
我们还可能会这么查看:
这个可以通过使用
ls -ltrh
来做到:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16➜ ls -ltrh
total 500K
-rw-r--r-- 1 ilbsmart staff 0 Jul 28 00:00 test.pdf
-rw-r--r-- 1 ilbsmart staff 0 Jul 28 00:01 a.mp4
drwxr-xr-x 2 ilbsmart staff 64 Jul 28 00:01 dir1
-rw-r--r-- 1 ilbsmart staff 0 Jul 28 00:01 c
-rw-r--r-- 1 ilbsmart staff 0 Jul 28 00:01 d
-rw-r--r-- 1 ilbsmart staff 0 Jul 28 00:01 e
-rw-r--r-- 1 ilbsmart staff 0 Jul 28 00:01 m.c
-rw-r--r-- 1 ilbsmart staff 0 Jul 28 00:01 s.js
-rw-r--r-- 1 ilbsmart staff 500K Jul 28 00:08 big_one
# -l 显示更详细的信息
# -t是指按照时间从最新到最老来排序
# -r reserve sort, 有的时候目录下文件太多, 我们更希望最后显示的是最新的文件, 也就是说, 从最老到最新排序, 可以加上这个参数
# -h 以人类可以看懂的方式显示size, 默认其实是以字节数来显示每个entry的大小的.更多
常用的还有
ls -R
: 递归显示当前目录下所有目录下的文件.ls *.js
只显示后缀是.js
的文件
文章转载自:比克王国
原文作者: dgb8901,yinxing
原文链接: https://www.itwork.club/2018/08/01/Shell-Command-ls/
版权声明: 转载请注明出处
为您推荐

体验小程序「简易记账」

关注公众号「特想学英语」