Solved

Solaris find command- ignore subdirectories

Posted on 2008-06-11
5
1,677 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to Change Interface on Cisco IOU 11 110
Skill Development 15 182
Python Assistance 7 86
Thin secure Windows 10 5 102
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

809 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