This would print the size of all files in the current folder and subfolders.
So it works like awk, but with full Perl, no need to learn awk syntax. You can do conditionals, loops and whatnot. I write 30% of my one time throw away scripts directly in the command line.
Comments
My 2012 top, in order of usage:
joe, ls, cd, time, cdbdump, tail, more, cat, rm, grep, wc, apachectl restart, find, curl, chmod, history, mv, locate, cpan, apt-get, pwd
But the most useful one is a command line Perl utility I called "flt" that executes a block of perl code for each in the stdin.
cat file.txt | flt ' $line=~ s|\s+| |gsi; print $line."\n"; '
That would compact free spaces
find . | flt ' if (-f $line) { print (-s $line)."\n"; } '
This would print the size of all files in the current folder and subfolders.
So it works like awk, but with full Perl, no need to learn awk syntax. You can do conditionals, loops and whatnot. I write 30% of my one time throw away scripts directly in the command line.
Are you familiar with perl's -n and -p switches?
http://perldoc.perl.org/perlrun.html#*-n*
Those "flt" lines could be written
(-l chomps the incoming newlines, and puts them back on the output)Of course, "perl -ne" is longer than "flt", and I appreciate all this implicit use of $_ is not to everyone's tastes.
Yes, but I bundled slightly better syntactic sugar in my tool. It's the same, in essence.