*BSD News Article 46522


Return to BSD News archive

Xref: sserve comp.unix.misc:17562 comp.unix.admin:30261 comp.unix.bsd:16669 comp.unix.programmer:26821 comp.unix.questions:66347 comp.unix.shell:23432
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msunews!agate!howland.reston.ans.net!vixen.cso.uiuc.edu!news.ksu.ksu.edu!hobbes.physics.uiowa.edu!newsrelay.iastate.edu!news.iastate.edu!pv740d.vincent.iastate.edu!gora
From: gora@iastate.edu (Gora Mohanty)
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: 8 Jul 95 06:53:23 GMT
Organization: Iowa State University, Ames, Iowa
Lines: 17
Message-ID: <gora.805186403@pv740d.vincent.iastate.edu>
References: <3tk3dc$4ml@rcp6.elan.af.mil>
NNTP-Posting-Host: pv740d.vincent.iastate.edu

In <3tk3dc$4ml@rcp6.elan.af.mil> Jay J Oh <OHJ%CSCADPS@mhs.elan.af.mil> writes:

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

Use
    ls -l | grep "^d"

If you must use 'find,' try

find . -type d -print -maxdepth 1

                                   Regards,
                                      Gora