I have a program that is downloading some images into a folder. I want to count the number of images in the folder currently. I used a command like ls -1 download_folder | wc -l
.
But this command takes a lot of time to run(since I have already downloaded a lot of images). While this command is running, my downloader keeps on downloading the images.
And finally, my command returns the count. I wanted to know, from what timestamp this count is. Is it from the instant I started running the command or it gives the current latest count?
Edit: I tried validating for myself, but could not find any way. Thanks.
set -- *; echo $#
would be faster or slower. It still sorts, but only uses shell built-ins.ls -1
significantly. I tried 100,000 files.ls
takes 0m1.397s;ls -U
takes 0m0.209s;set -- *; echo $#
takes 0m8.933s.