Counting the files in a directory.
When I was doing my summer project, I downloaded the datasets into the server and unzipped the zip file. Since it has a large amount of files in the dir, I want to count the number of files just through the terminal.
First try
1 | ls -1 | wc -l |
Use this command after getting into the dir, it can count the number of files in the current dir. Note: the first 1
is ONE, and the second l
is the l
for large.
Result: it seems that I can’t perform well, since the speed is slow and need to spend a lot of time to get the result( I didn’t wait for that long to get the final result).
Note:
wc
is great when I search this command.
1 | wc -l < file.txt |
The first line of code can count the number of lines in a text file.
The second line of code can count the words in the text file.
Improvement to get my result
Since I have the nohup.out
, I can count the line number to know how many files I have uncompressed.
The uncompressing process is a really long journey…for my project
Reference
- Bash Prompt HOWTO: Counting Files in the Current Directory