*BSD News Article 46828


Return to BSD News archive

Xref: sserve comp.unix.misc:17699 comp.unix.admin:30473 comp.unix.bsd:16686 comp.unix.programmer:27046 comp.unix.questions:66686 comp.unix.shell:23642
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!oleane!dish.news.pipex.net!pipex!news.mathworks.com!gatech!gt-news!cc.gatech.edu!dragon
From: dragon@cc.gatech.edu (Musashi)
Newsgroups: comp.unix.misc,comp.unix.admin,comp.unix.bsd,comp.unix.programmer,comp.unix.questions,comp.unix.shell
Subject: Re: A Unix command to obtain directory name only
Date: 14 Jul 1995 01:58:30 -0400
Organization: College of Computing, Georgia Tech
Lines: 19
Message-ID: <3u5126$sjg@felix.cc.gatech.edu>
References: <3tk3dc$4ml@rcp6.elan.af.mil>
NNTP-Posting-Host: felix.cc.gatech.edu
NNTP-Posting-User: dragon

Jay J Oh  <OHJ%CSCADPS@mhs.elan.af.mil> wrote:
>
>
>I am trying to invoke a unix command to obtain only directory names 
>listing for a given path.  I tried using 'ls -d *', but this includes 
>files also.  I also tried 'find -type d . -print'  but this command 
>recursively list all the subdirectories, which I don't want.

(this is assuming a bourne shell derivative)
for i in *; do if [ -d $i ]; then echo $i; fi; done


...just 'cause no one else posted it,
Musashi
-- 
      /          "Meddle not in the affairs of dragons, for             \
 *}=={*}>======-  thou art crunchy and go well with ketchup."  -======<{*}=={*
      \                                                                 /
    Musashi                 dragon@cc.gatech.edu                    Musashi