Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1742
  • Last Modified:

Solaris find command- ignore subdirectories

I am looking for a simple script to do some cleanup on directories older than n days.  As part of that script, I need to do a find on directories within my pwd.  However, I only want the top level directories returned, not subdirectories.

For instance, give the following:
ls
/mydir
/mydir/myotherdir/mythirddir
/yourdir
/yourdir/yourotherdir/yourthirddir
file.txt
file.sh

I only want my find command to return mydir and yourdir

Again, this is on solaris, so I don't have maxdepth.
0
krussell222
Asked:
krussell222
3 Solutions
 
ozoCommented:
do you have -prune
0
 
ozoCommented:
find .  ! -name . -prune
0
 
krussell222Author Commented:
yes
0
 
omarfaridCommented:
try

ls | while read line
do
   if [ -d $line ]
   then
        echo $line
   fi
done
0
 
TintinCommented:

ls -1F|grep /

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now