[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Unix 101: ls with file count

Wienand Ian wrote:

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).
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.

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 adding up.

Thanks for the alias Robert, and the tip Weinand (and the neat python script from Ron); it's great!


To UNSUBSCRIBE, email to debian-user-request@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Reply to: