递归地计算Linux目录中的文件。

时间:2022-12-01 21:49:43

How can I recursively count files in a Linux directory?

如何在Linux目录中递归地计数文件?

I found this:

我发现这个:

find DIR_NAME -type f ¦ wc -l

But when I run this it returns the following error.

但是当我运行它时,它会返回以下错误。

find: paths must precede expression: ¦

找到:路径必须先于表达:。

19 个解决方案

#1


788  

This should work:

这应该工作:

find DIR_NAME -type f | wc -l

Explanation:

解释:

  • -type f to include only files.
  • -类型f只包含文件。
  • | (and not ¦) redirects find command's standard output to wc command's standard input.
  • |(而不是¦)发现wc命令的标准输出重定向命令的标准输入。
  • wc (short for word count) counts newlines, words and bytes on its input (docs).
  • wc(单词计数的缩写)在其输入(文档)中计算新行、单词和字节。
  • -l to count just newlines.
  • -我只计算换行数。

Notes:

注:

  • Replace DIR_NAME with . to execute the command in the current folder.
  • DIR_NAME替换。在当前文件夹中执行该命令。
  • You can also remove the -type f to include directories (and symlinks) in the count.
  • 您还可以删除-type f以在计数中包含目录(和符号链接)。
  • It's possible this command will overcount if filenames can contain newline characters.
  • 如果文件名可以包含换行符,那么这个命令可能会被忽略。

Explanation of why your example does not work:

解释为什么你的例子不起作用:

In the command you showed, you do not use the "Pipe" (|) to kind-of connect two commands, but the broken bar (¦) which the shell does not recognize as a command or something similar. That's why you get that error message.

在您显示的命令,你不使用“管道”(|)的连接两个命令,但是破碎的酒吧(¦),外壳不承认作为一个命令或类似的东西。这就是为什么你会得到错误信息。

#2


49  

For the current directory:

当前目录:

find . -type f | wc -l

#3


37  

If you want a breakdown of how many files are in each dir under your current dir:

如果你想要细分你当前目录下的每个目录中有多少个文件:

for i in $(find . -maxdepth 1 -type d) ; do 
    echo -n $i": " ; 
    (find $i -type f | wc -l) ; 
done

That can go all on one line, of course. The parenthesis clarify whose output wc -l is supposed to be watching (find $i -type f in this case).

当然,这可以是一条直线。括号说明了输出wc -l应该是什么(在这个例子中找到$i -type f)。

#4


31  

You can use

您可以使用

$ tree

after installing the tree package with

在安装了树包之后。

$ sudo apt-get install tree

(on a Debian / Mint / Ubuntu Linux machine).

(在Debian / Mint / Ubuntu Linux机器上)。

The command shows not only the count of the files, but also the count of the directories, separately. The option -L can be used to specify the maximum display level (which, by default, is the maximum depth of the directory tree).

该命令不仅显示了文件的计数,还显示了目录的计数。选项-L可以用来指定最大显示级别(默认情况下,这是目录树的最大深度)。

Hidden files can be included too by supplying the -a option .

通过提供-a选项也可以包含隐藏文件。

#5


26  

On my computer, rsync is a little bit faster than find | wc -l in the accepted answer. For example you can count the files in /Users/joe/ like this:

在我的计算机上,rsync比在接受的答案中找到| wc -l要快一些。例如,您可以计算/ user /joe/这样的文件:

[joe:~] $ rsync --stats --dry-run -ax /Users/joe/ /xxx

Number of files: 173076
Number of files transferred: 150481
Total file size: 8414946241 bytes
Total transferred file size: 8414932602 bytes

The second line has the number of files, 150,481 in the above example. As a bonus you get the total size as well (in bytes).

第二行有文件的数量,在上面的例子中是150,481。此外,您还可以获得总大小(以字节为单位)。

Remarks:

备注:

  • the first line is a count of files, directories, symlinks, etc all together, that's why it is bigger than the second line.
  • 第一行是文件、目录、符号链接等的计数,这就是为什么它比第二行大。
  • the --dry-run (or -n for short) option is important to not actually transfer the files!
  • -- -干运行(或-n)选项对于不实际传输文件很重要!
  • the /xxx parameter can be any empty or non existing folder. Don't use / here.
  • xxx参数可以是任何空的或不存在的文件夹。这里不使用/。
  • I used the -x option to "don't cross filesystem boundaries", which means if you execute it for / and you have external hard disks attached, it will only count the files on the root partition.
  • 我使用-x选项“不要跨越文件系统边界”,这意味着如果您执行它,并且附加了外部硬盘,它只会计算根分区上的文件。

#6


11  

Combining several of the answers here together, the most useful solution seems to be:

把几个答案结合在一起,最有用的解决办法似乎是:

find . -maxdepth 1 -type d -print0 | xargs -0 -I {} sh -c 'echo -e $(find "{}" -printf "\n" | wc -l) "{}"' | sort -n

It can handle odd things like file names that include spaces parenthesis and even new lines. It also sorts the output by the number of files.

它可以处理一些奇怪的事情,比如文件名称,包括空格括号,甚至是新行。它还根据文件的数量对输出进行排序。

You can increase the number after -maxdepth to get sub directories counted too. Keep in mind that this can potentially take a long time, particularly if you have a highly nested directory structure in combination with a high -maxdepth number.

您可以增加-maxdepth的数字以获得子目录。请记住,这可能需要很长时间,特别是如果您有一个高度嵌套的目录结构和一个高maxdepth值。

#7


7  

If you want to know how many files and sub-directories exist from the present working directory you can use this one-liner

如果您想知道当前工作目录中存在多少个文件和子目录,您可以使用这一行。

find . -maxdepth 1 -type d -print0 | xargs -0 -I {} sh -c 'echo -e $(find {} | wc -l) {}' | sort -n

This will work in GNU flavour, and just omit the -e from the echo command for BSD linux (e.g. OSX).

这将在GNU的味道中发挥作用,并从BSD linux的echo命令中省略-e(例如OSX)。

#8


6  

If you want to avoid error cases, don't allow wc -l to see files with newlines (which it will count as 2+ files)

如果您想避免错误,请不要允许wc -l看到带有新行的文件(它将被视为2+文件)

e.g. Consider a case where we have a single file with a single EOL character in it

考虑这样一个例子,我们有一个单独的文件,其中有一个EOL字符。

> mkdir emptydir && cd emptydir
> touch $'file with EOL(\n) character in it'
> find -type f
./file with EOL(?) character in it
> find -type f | wc -l
2

Since at least gnu wc does not appear to have an option to read/count a null terminated list (except from a file), the easiest solution would just be to not pass it filenames, but a static output each time a file is found, e.g. in the same directory as above

因为至少gnu wc似乎没有一个选项来读取/计数一个空终止列表(除了一个文件之外),最简单的解决方案就是不通过它的文件名,而是每次找到一个文件时的静态输出,例如在上面的同一个目录中。

> find -type f -exec printf '\n' \; | wc -l
1

Or if your find supports it

或者如果你的发现支持它。

> find -type f -printf '\n' | wc -l
1 

#9


3  

To determine how many files there are in the current directory, put in ls -1 | wc -l. This uses wc to do a count of the number of lines (-l) in the output of ls -1. It doesn't count dotfiles. Please note that ls -l (that's an "L" rather than a "1" as in the previous examples) which I used in previous versions of this HOWTO will actually give you a file count one greater than the actual count. Thanks to Kam Nejad for this point.

要确定当前目录中有多少个文件,请输入ls -1 | wc -l。它使用wc来计算ls -1输出的行数(-l)。.它不计数。请注意ls -l(这是一个“L”,而不是前面的例子中的“1”),我在这个HOWTO的以前版本中使用过,它实际上会给您一个大于实际计数的文件数。感谢Kam Nejad的这一点。

If you want to count only files and NOT include symbolic links (just an example of what else you could do), you could use ls -l | grep -v ^l | wc -l (that's an "L" not a "1" this time, we want a "long" listing here). grep checks for any line beginning with "l" (indicating a link), and discards that line (-v).

如果你想只统计文件和不包括符号链接(只是一个例子,你可以做什么),您可以使用ls - l | grep - v ^ l | wc - l(这是一个“l”不是一个“1”这一次,我们想要一个“长”清单)。grep检查以“l”开头的任何行(指示一个链接),并丢弃该行(-v)。

Relative speed: "ls -1 /usr/bin/ | wc -l" takes about 1.03 seconds on an unloaded 486SX25 (/usr/bin/ on this machine has 355 files). "ls -l /usr/bin/ | grep -v ^l | wc -l" takes about 1.19 seconds.

相对速度:“ls -1 / usr/bin/| wc -l”在卸载的486SX25 (/usr/bin/在这台机器上有355个文件)上大约需要1.03秒。“ls - l /usr/bin/ | grep - v ^ l | wc - l”大约需要1.19秒。

Source: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x700.html

来源:http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x700.html

#10


1  

I have written ffcnt to speed up recursive file counting under specific circumstances: rotational disks and filesystems that support extent mapping.

我已经编写了ffcnt以加速在特定情况下的递归文件计数:支持范围映射的旋转磁盘和文件系统。

It can be an order of magnitude faster than ls or find based approaches, but YMMV.

它可以是一个数量级的速度比ls或寻找的方法,但是YMMV。

#11


0  

You could try :

你可以试试:

find `pwd` -type f -exec ls -l {} ; | wc -l

#12


0  

I would like to give a different approach with filtering for format. Example counts all available grub kernel modules:

我想用一种不同的方式来过滤格式。示例计算所有可用的grub内核模块:

ls -l /boot/grub/*.mod | wc -l

ls - l / boot / grub / *。国防部| wc - l

#13


0  

There are many correct answers here. Here's another!

这里有很多正确的答案。这是另一个!

find . -type f | sort | uniq -w 10 -c

where . is the folder to look in and 10 is the number of characters by which to group the directory.

在哪里。是要查找的文件夹,10是将目录分组的字符数。

#14


0  

With bash:

bash:

Create an array of entries with ( ) and get the count with #.

使用()创建一个条目数组,并使用#来获取计数。

FILES=(./*); echo ${#FILES[@]}

Ok that doesn't recursively count files but I wanted to show the simple option first. A common use case might be for creating rollover backups of a file. This will create logfile.1, logfile.2, logfile.3 etc.

它不会递归地计算文件,但我想先展示一个简单的选项。一个常见的用例可能是创建文件的翻转备份。这将创建日志文件。1,日志文件。2,日志文件。3等。

CNT=(./logfile*); mv logfile logfile.${#CNT[@]}

To get the count of files recursively we can still use find in the same way.

要递归地获取文件计数,我们仍然可以用同样的方法使用find。

FILES=(`find . -type f`); echo ${#FILES[@]}

#15


0  

find -type f | wc -l

找到f型| wc -l。

OR (If directory is current directory)

或(如果目录是当前目录)

find . -type f | wc -l

找到。- f型| wc -l。

#16


0  

Since filenames in UNIX may contain newlines (yes, newlines), wc -l might count too many files. I would print a dot for every file and then count the dots:

由于UNIX中的文件名可能包含换行符(是的,换行符),所以wc -l可能会计算太多的文件。我会为每个文件打印一个点,然后计算点:

find DIR_NAME -type f -printf "." | wc -c

#17


0  

You can use the command ncdu. It will recursively count how many files a Linux directory contains. Here is an example of output:

您可以使用命令ncdu。它将递归地计算一个Linux目录包含多少个文件。下面是一个输出示例:

递归地计算Linux目录中的文件。

It has a progress bar, which is convenient if you have many files:

它有一个进度条,如果你有很多文件,这很方便:

递归地计算Linux目录中的文件。

To install it on Ubuntu:

安装在Ubuntu上:

sudo apt-get install -y ncdu

Benchmark: I used https://archive.org/details/cv_corpus_v1.tar (380390 files, 11 GB) as the folder where one has to count the number of files.

基准:我使用https://archive.org/details/cv_corpus_v1.tar(380390文件,11 GB)作为文件夹,其中一个必须计算文件的数量。

  • find . -type f | wc -l: around 1m20s to complete
  • 找到。- f型| wc -l:大约1m20左右。
  • ncdu: around 1m20s to complete
  • ncdu:大约1m20左右。

#18


-1  

ls -l | grep -e -x -e -dr | wc -l

l | grep -e -x -e -dr |。

1.long list 2.filter files and dirs 3.count the filtered line no

1。长长的清单2所示。过滤文件和dirs3。计算过滤后的行号。

#19


-1  

This will work completely fine. Simple short. If you want to count the number of files present in a folder.

这完全没问题。简单的短。如果要计算文件夹中当前文件的数量。

ls | wc -l

#1


788  

This should work:

这应该工作:

find DIR_NAME -type f | wc -l

Explanation:

解释:

  • -type f to include only files.
  • -类型f只包含文件。
  • | (and not ¦) redirects find command's standard output to wc command's standard input.
  • |(而不是¦)发现wc命令的标准输出重定向命令的标准输入。
  • wc (short for word count) counts newlines, words and bytes on its input (docs).
  • wc(单词计数的缩写)在其输入(文档)中计算新行、单词和字节。
  • -l to count just newlines.
  • -我只计算换行数。

Notes:

注:

  • Replace DIR_NAME with . to execute the command in the current folder.
  • DIR_NAME替换。在当前文件夹中执行该命令。
  • You can also remove the -type f to include directories (and symlinks) in the count.
  • 您还可以删除-type f以在计数中包含目录(和符号链接)。
  • It's possible this command will overcount if filenames can contain newline characters.
  • 如果文件名可以包含换行符,那么这个命令可能会被忽略。

Explanation of why your example does not work:

解释为什么你的例子不起作用:

In the command you showed, you do not use the "Pipe" (|) to kind-of connect two commands, but the broken bar (¦) which the shell does not recognize as a command or something similar. That's why you get that error message.

在您显示的命令,你不使用“管道”(|)的连接两个命令,但是破碎的酒吧(¦),外壳不承认作为一个命令或类似的东西。这就是为什么你会得到错误信息。

#2


49  

For the current directory:

当前目录:

find . -type f | wc -l

#3


37  

If you want a breakdown of how many files are in each dir under your current dir:

如果你想要细分你当前目录下的每个目录中有多少个文件:

for i in $(find . -maxdepth 1 -type d) ; do 
    echo -n $i": " ; 
    (find $i -type f | wc -l) ; 
done

That can go all on one line, of course. The parenthesis clarify whose output wc -l is supposed to be watching (find $i -type f in this case).

当然,这可以是一条直线。括号说明了输出wc -l应该是什么(在这个例子中找到$i -type f)。

#4


31  

You can use

您可以使用

$ tree

after installing the tree package with

在安装了树包之后。

$ sudo apt-get install tree

(on a Debian / Mint / Ubuntu Linux machine).

(在Debian / Mint / Ubuntu Linux机器上)。

The command shows not only the count of the files, but also the count of the directories, separately. The option -L can be used to specify the maximum display level (which, by default, is the maximum depth of the directory tree).

该命令不仅显示了文件的计数,还显示了目录的计数。选项-L可以用来指定最大显示级别(默认情况下,这是目录树的最大深度)。

Hidden files can be included too by supplying the -a option .

通过提供-a选项也可以包含隐藏文件。

#5


26  

On my computer, rsync is a little bit faster than find | wc -l in the accepted answer. For example you can count the files in /Users/joe/ like this:

在我的计算机上,rsync比在接受的答案中找到| wc -l要快一些。例如,您可以计算/ user /joe/这样的文件:

[joe:~] $ rsync --stats --dry-run -ax /Users/joe/ /xxx

Number of files: 173076
Number of files transferred: 150481
Total file size: 8414946241 bytes
Total transferred file size: 8414932602 bytes

The second line has the number of files, 150,481 in the above example. As a bonus you get the total size as well (in bytes).

第二行有文件的数量,在上面的例子中是150,481。此外,您还可以获得总大小(以字节为单位)。

Remarks:

备注:

  • the first line is a count of files, directories, symlinks, etc all together, that's why it is bigger than the second line.
  • 第一行是文件、目录、符号链接等的计数,这就是为什么它比第二行大。
  • the --dry-run (or -n for short) option is important to not actually transfer the files!
  • -- -干运行(或-n)选项对于不实际传输文件很重要!
  • the /xxx parameter can be any empty or non existing folder. Don't use / here.
  • xxx参数可以是任何空的或不存在的文件夹。这里不使用/。
  • I used the -x option to "don't cross filesystem boundaries", which means if you execute it for / and you have external hard disks attached, it will only count the files on the root partition.
  • 我使用-x选项“不要跨越文件系统边界”,这意味着如果您执行它,并且附加了外部硬盘,它只会计算根分区上的文件。

#6


11  

Combining several of the answers here together, the most useful solution seems to be:

把几个答案结合在一起,最有用的解决办法似乎是:

find . -maxdepth 1 -type d -print0 | xargs -0 -I {} sh -c 'echo -e $(find "{}" -printf "\n" | wc -l) "{}"' | sort -n

It can handle odd things like file names that include spaces parenthesis and even new lines. It also sorts the output by the number of files.

它可以处理一些奇怪的事情,比如文件名称,包括空格括号,甚至是新行。它还根据文件的数量对输出进行排序。

You can increase the number after -maxdepth to get sub directories counted too. Keep in mind that this can potentially take a long time, particularly if you have a highly nested directory structure in combination with a high -maxdepth number.

您可以增加-maxdepth的数字以获得子目录。请记住,这可能需要很长时间,特别是如果您有一个高度嵌套的目录结构和一个高maxdepth值。

#7


7  

If you want to know how many files and sub-directories exist from the present working directory you can use this one-liner

如果您想知道当前工作目录中存在多少个文件和子目录,您可以使用这一行。

find . -maxdepth 1 -type d -print0 | xargs -0 -I {} sh -c 'echo -e $(find {} | wc -l) {}' | sort -n

This will work in GNU flavour, and just omit the -e from the echo command for BSD linux (e.g. OSX).

这将在GNU的味道中发挥作用,并从BSD linux的echo命令中省略-e(例如OSX)。

#8


6  

If you want to avoid error cases, don't allow wc -l to see files with newlines (which it will count as 2+ files)

如果您想避免错误,请不要允许wc -l看到带有新行的文件(它将被视为2+文件)

e.g. Consider a case where we have a single file with a single EOL character in it

考虑这样一个例子,我们有一个单独的文件,其中有一个EOL字符。

> mkdir emptydir && cd emptydir
> touch $'file with EOL(\n) character in it'
> find -type f
./file with EOL(?) character in it
> find -type f | wc -l
2

Since at least gnu wc does not appear to have an option to read/count a null terminated list (except from a file), the easiest solution would just be to not pass it filenames, but a static output each time a file is found, e.g. in the same directory as above

因为至少gnu wc似乎没有一个选项来读取/计数一个空终止列表(除了一个文件之外),最简单的解决方案就是不通过它的文件名,而是每次找到一个文件时的静态输出,例如在上面的同一个目录中。

> find -type f -exec printf '\n' \; | wc -l
1

Or if your find supports it

或者如果你的发现支持它。

> find -type f -printf '\n' | wc -l
1 

#9


3  

To determine how many files there are in the current directory, put in ls -1 | wc -l. This uses wc to do a count of the number of lines (-l) in the output of ls -1. It doesn't count dotfiles. Please note that ls -l (that's an "L" rather than a "1" as in the previous examples) which I used in previous versions of this HOWTO will actually give you a file count one greater than the actual count. Thanks to Kam Nejad for this point.

要确定当前目录中有多少个文件,请输入ls -1 | wc -l。它使用wc来计算ls -1输出的行数(-l)。.它不计数。请注意ls -l(这是一个“L”,而不是前面的例子中的“1”),我在这个HOWTO的以前版本中使用过,它实际上会给您一个大于实际计数的文件数。感谢Kam Nejad的这一点。

If you want to count only files and NOT include symbolic links (just an example of what else you could do), you could use ls -l | grep -v ^l | wc -l (that's an "L" not a "1" this time, we want a "long" listing here). grep checks for any line beginning with "l" (indicating a link), and discards that line (-v).

如果你想只统计文件和不包括符号链接(只是一个例子,你可以做什么),您可以使用ls - l | grep - v ^ l | wc - l(这是一个“l”不是一个“1”这一次,我们想要一个“长”清单)。grep检查以“l”开头的任何行(指示一个链接),并丢弃该行(-v)。

Relative speed: "ls -1 /usr/bin/ | wc -l" takes about 1.03 seconds on an unloaded 486SX25 (/usr/bin/ on this machine has 355 files). "ls -l /usr/bin/ | grep -v ^l | wc -l" takes about 1.19 seconds.

相对速度:“ls -1 / usr/bin/| wc -l”在卸载的486SX25 (/usr/bin/在这台机器上有355个文件)上大约需要1.03秒。“ls - l /usr/bin/ | grep - v ^ l | wc - l”大约需要1.19秒。

Source: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x700.html

来源:http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x700.html

#10


1  

I have written ffcnt to speed up recursive file counting under specific circumstances: rotational disks and filesystems that support extent mapping.

我已经编写了ffcnt以加速在特定情况下的递归文件计数:支持范围映射的旋转磁盘和文件系统。

It can be an order of magnitude faster than ls or find based approaches, but YMMV.

它可以是一个数量级的速度比ls或寻找的方法,但是YMMV。

#11


0  

You could try :

你可以试试:

find `pwd` -type f -exec ls -l {} ; | wc -l

#12


0  

I would like to give a different approach with filtering for format. Example counts all available grub kernel modules:

我想用一种不同的方式来过滤格式。示例计算所有可用的grub内核模块:

ls -l /boot/grub/*.mod | wc -l

ls - l / boot / grub / *。国防部| wc - l

#13


0  

There are many correct answers here. Here's another!

这里有很多正确的答案。这是另一个!

find . -type f | sort | uniq -w 10 -c

where . is the folder to look in and 10 is the number of characters by which to group the directory.

在哪里。是要查找的文件夹,10是将目录分组的字符数。

#14


0  

With bash:

bash:

Create an array of entries with ( ) and get the count with #.

使用()创建一个条目数组,并使用#来获取计数。

FILES=(./*); echo ${#FILES[@]}

Ok that doesn't recursively count files but I wanted to show the simple option first. A common use case might be for creating rollover backups of a file. This will create logfile.1, logfile.2, logfile.3 etc.

它不会递归地计算文件,但我想先展示一个简单的选项。一个常见的用例可能是创建文件的翻转备份。这将创建日志文件。1,日志文件。2,日志文件。3等。

CNT=(./logfile*); mv logfile logfile.${#CNT[@]}

To get the count of files recursively we can still use find in the same way.

要递归地获取文件计数,我们仍然可以用同样的方法使用find。

FILES=(`find . -type f`); echo ${#FILES[@]}

#15


0  

find -type f | wc -l

找到f型| wc -l。

OR (If directory is current directory)

或(如果目录是当前目录)

find . -type f | wc -l

找到。- f型| wc -l。

#16


0  

Since filenames in UNIX may contain newlines (yes, newlines), wc -l might count too many files. I would print a dot for every file and then count the dots:

由于UNIX中的文件名可能包含换行符(是的,换行符),所以wc -l可能会计算太多的文件。我会为每个文件打印一个点,然后计算点:

find DIR_NAME -type f -printf "." | wc -c

#17


0  

You can use the command ncdu. It will recursively count how many files a Linux directory contains. Here is an example of output:

您可以使用命令ncdu。它将递归地计算一个Linux目录包含多少个文件。下面是一个输出示例:

递归地计算Linux目录中的文件。

It has a progress bar, which is convenient if you have many files:

它有一个进度条,如果你有很多文件,这很方便:

递归地计算Linux目录中的文件。

To install it on Ubuntu:

安装在Ubuntu上:

sudo apt-get install -y ncdu

Benchmark: I used https://archive.org/details/cv_corpus_v1.tar (380390 files, 11 GB) as the folder where one has to count the number of files.

基准:我使用https://archive.org/details/cv_corpus_v1.tar(380390文件,11 GB)作为文件夹,其中一个必须计算文件的数量。

  • find . -type f | wc -l: around 1m20s to complete
  • 找到。- f型| wc -l:大约1m20左右。
  • ncdu: around 1m20s to complete
  • ncdu:大约1m20左右。

#18


-1  

ls -l | grep -e -x -e -dr | wc -l

l | grep -e -x -e -dr |。

1.long list 2.filter files and dirs 3.count the filtered line no

1。长长的清单2所示。过滤文件和dirs3。计算过滤后的行号。

#19


-1  

This will work completely fine. Simple short. If you want to count the number of files present in a folder.

这完全没问题。简单的短。如果要计算文件夹中当前文件的数量。

ls | wc -l