简体   繁体   中英

Counting file with linux command

I am a new linux user. I am trying to count all of file files in the home(~) directory. So did it in the following steps -

  1. ls -1 > fileCount # list each file in separate line and places them in fileCount
  2. wc -l fileCount # word count from the file fileCount

The procedure above gives me the correct file count. But it is a bit lengthy process and require a file to be generated.

Is there any better way to count all the file from the current directory?

Thanks in advance.

You can try with this

ls -1 | wc -l

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM