Re: Unix 101: ls with file count
Wienand Ian wrote:
Actually, it worked just fine when I copied/pasted it. I'm using bash.
As you suggested, I replaced the double-quotes with singles, and it
works the same. Or it appears to at least.
Chain commands in an alias:
alias dols="ls; echo `ls -l | grep ^d | wc -l` directories; echo `ls -l |
grep ^- | wc -l` files"
customize as needed
If you're wondering why you copied and pasted this in it didn't work but
just constantly showed you the stats for the directory you were in when you
executed it, then make sure you replaced the " (double quotes) with '
(single quotes). Otherwise your shell will expand the stuff in between the
` ` rather than taking it literally (in general, " means everything in here
is a string, but expand what you can whilst ' means everything in here is a
string, don't expand anything).
However, when I added ";ls | wc -l` Total Files'" to the end, I get a
count of 16 directories, 8 files, and 25 Total Items. Something's not
Thanks for the alias Robert, and the tip Weinand (and the neat python
script from Ron); it's great!
To UNSUBSCRIBE, email to firstname.lastname@example.org
with a subject of "unsubscribe". Trouble? Contact email@example.com