ls -1 | wc
I knew there are lots of files but after 2-3 minutes I decided this is not a joke any more so I wrote the following:
It finished in under 1 sec, printed 239982 so I could kill the other process....#!/usr/bin/perl -w use strict; my $dir = $ARGV[0] || "."; opendir my $dh, $dir or die "Could not open '$dir'\n"; my $c =0; $c++ while readdir $dh; print "$c\n";
Thank you.
In reply to Using Perl saves time.... by szabgab
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |