我的朋友刚刚通过这个命令来计算目录中的文件数量:
$ ls -lt | wc -l
有人可以帮助我清除这个命令的含义吗?我知道ls
是要列出所有文件。但-lt
是什么意思?
另外,如果我使用ls | wc -l
但没有-lt
选项,我会得到不同的计数。为什么会这样?
答案 0 :(得分:5)
您需要熟悉“man(手册)页面”:
$ man ls
在这种情况下,你会看到:
-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.
另一种可以看到选项效果的方法是运行ls
而不管道wc
命令。比较
$ ls
与
$ ls -l
和
$ ls -lt