Solved

Solaris find command- ignore subdirectories

Posted on 2008-06-11
5
1,663 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
Comment Utility
do you have -prune
0
 
LVL 84

Accepted Solution

by:
ozo earned 200 total points
Comment Utility
find .  ! -name . -prune
0
 

Author Comment

by:krussell222
Comment Utility
yes
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 200 total points
Comment Utility
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
Comment Utility

ls -1F|grep /

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hibernate methods 2 58
How to Change Interface on Cisco IOU 11 72
zeroMAx challenge 20 76
Linux: disable vim auto-comment 7 61
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now