Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rutgers!deejay!gear!cadlab!staff From: staff@cadlab.sublink.ORG (Alex Martelli) Newsgroups: comp.unix.questions Subject: Re: Can ls be made to only list directories? Message-ID: <259@cadlab.sublink.ORG> Date: 6 Sep 90 15:59:38 GMT References: <90243.151817SML108@psuvm.psu.edu> <13725@smoke.BRL.MIL> <57@raysnec.UUCP> Organization: CAD.LAB, Bologna, Italia Lines: 22 shwake@raysnec.UUCP (Ray Shwake) writes: >Create a shell script - call it dirs - then run "dirs *" >for i in `file $* | fgrep directory | sed 's/\([^:]*\):.*/\1/'` >do > /bin/echo "$i \c" # feel free to modify for built-in echo >done >echo Just a little observation - 's/:.*//' seems a tad simpler than the sed command suggested (I use it all the time for similar purposes, e.g. "file * | fgrep text | sed 's/:.*//' | xargs ls -l", interactively, to long-list text-files only). Either will give problems on filenames with embedded colons, but my suggestion's a bit easier to fix - just place a tab between the colon and the dot. -- Alex Martelli - CAD.LAB s.p.a., v. Stalingrado 45, Bologna, Italia Email: (work:) staff@cadlab.sublink.org, (home:) alex@am.sublink.org Phone: (work:) ++39 (51) 371099, (home:) ++39 (51) 250434; Fax: ++39 (51) 366964 (work only; any time of day or night).