Solved

Solaris find command- ignore subdirectories

Posted on 2008-06-11
5
1,671 Views
Last Modified: 2013-12-27
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
Comment
Question by:krussell222
5 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 21763651
do you have -prune
0
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
ID: 21763689
find .  ! -name . -prune
0
 

Author Comment

by:krussell222
ID: 21763694
yes
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 200 total points
ID: 21765918
try

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

Assisted Solution

by:Tintin
Tintin earned 100 total points
ID: 21766114

ls -1F|grep /

Open in new window

0

Featured Post

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem Imaging Computers With Clonezilla 2 90
post4 challenge 28 100
can't umount nfs share after server goes offline... 4 83
cron job says it ran, no results 25 118
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question