A Generation Lost in the Bazaar - Poul-Henning Kamp article

Chris F.A. Johnson chris-E7bvbYbpR6jSUeElwK9/Pw at public.gmane.org
Wed Aug 22 22:41:33 UTC 2012


On Wed, 22 Aug 2012, phiscock-g851W1bGYuGnS0EtXVNi6w at public.gmane.org wrote:

>>> Why is it that the ls command doesn't
>>> have an option of showing only directories?
>>
>> ls -d */
>>
>>
> Sure, but why do I have to add the cryptic */ to this?

   Because that's what you want.

> Why not just ls -d?

   Because that does something different.

   I use this function to list directories:

ld() #@ List directories
{
     ld_dir=$1
     set -- ${1:+"$1/"}*/
     [ -d "${1:-.}" ] || return 5
     ls -ld ${ld_dir:+$ld_dir/}*/ 2>/dev/null
}

-- 
    Chris F.A. Johnson, <http://cfajohnson.com/>
    Author:
    Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list