我的朋友刚刚通过这个命令来计算目录中的文件数:
$ ls -lt | wc -l
Run Code Online (Sandbox Code Playgroud)
有人可以帮我清除这个命令的含义吗?我知道那ls就是列出所有文件.但是什么-lt意思呢?
另外,如果我ls | wc -l没有-lt选项,我会得到不同的计数.为什么会这样?
你想要熟悉"man(手册)页面":
$ man ls
Run Code Online (Sandbox Code Playgroud)
在这种情况下,您将看到:
-l (The lowercase letter ``ell''.) List in long format. (See below.) If
the output is to a terminal, a total sum for all the file sizes is
output on a line before the long listing.
-t Sort by time modified (most recently modified first) before sorting the
operands by lexicographical order.
Run Code Online (Sandbox Code Playgroud)
另一种可以看到选项效果的方法是在ls没有管道的情况wc下运行命令.相比
$ ls
Run Code Online (Sandbox Code Playgroud)
同
$ ls -l
Run Code Online (Sandbox Code Playgroud)
和
$ ls -lt
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1943 次 |
| 最近记录: |