Solaris find without maxdepth


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Solaris find without maxdepth
# 1  
Old 01-12-2009
Solaris find without maxdepth

Hi, I am using Solaris 5.8

I searched online, the find command has an option called maxdepth which can be used to limit the number of directories find will look into.

Code:
find . -maxdepth 2 -type f

When I run the above command in solaris, I get an error

Code:
find: bad option -maxdepth
find: path-list predicate-list

It seems this version of solaris does not support the maxdepth.

Is there any way to get the same results with other commands ?
# 2  
Old 01-13-2009
You can use -prune to simulate -maxdepth 1, but -maxdepth 2 is not as easy.

This should be equivalent:

Code:
find . -type f  | grep -v '^./.*/.*/'

# 3  
Old 01-14-2009
Quote:
Originally Posted by Annihilannic
You can use -prune to simulate -maxdepth 1, but -maxdepth 2 is not as easy.

This should be equivalent:

Code:
find . -type f  | grep -v '^./.*/.*/'


Thank you for your reply
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What is wrong with 'find . -maxdepth 1 -ctime -7 -type f'?

Have you tried running the command below? On the same RHEl 6.8 or 6.6. It will give you different output. find . -maxdepth 1 -ctime -7 -type f rpm -qa|grep find findutils-4.4.2-9.el6.x86_64 # cat /etc/redhat-release Red Hat Enterprise Linux Server release 6.8 (Santiago) # (6 Replies)
Discussion started by: invinzin21
6 Replies

2. Shell Programming and Scripting

Maxdepth option of find command not working

Can you please figure out what is the issue here $ find . -maxdepth 1 -type f -size 0 -print find: bad option -maxdepth please find the OS details $ uname -a HP-UX g5u1216 B.11.31 U ia64 2614088426 unlimited-user license Use code tags, thanks. (6 Replies)
Discussion started by: TomG
6 Replies

3. Shell Programming and Scripting

Maxdepth command not working in AIX.Need alternative solution for this command

Hi All, I am trying to select 30 days older files under current directory ,but not from subdirectory using below command. find <Dir> -type f -mtime + 30 This command selecting all the files from current directory and also from sub directory . I read some documention through internet ,... (1 Reply)
Discussion started by: kommineni
1 Replies

4. UNIX for Dummies Questions & Answers

I want alternative of -maxdepth 1 for all Linux,Solaris and AIX

find /full/path/dir \( ! -name dir -o -type f \) -prune -type f on AIX it worked perfect : sdp1:/var/tmp/test# find /var/tmp/test/ \( ! -name test -o -type f \) -prune \ -name "*properties" -type f -exec ls -l {} \; -exec cksum {} \; -rw------- 1 root system 19 Dec 12... (5 Replies)
Discussion started by: laxmikant.hcl
5 Replies

5. Solaris

Is it possible to find the seek rate of the find command in Solaris?

Hello, I am running some performance based tests on Solaris, and I was wondering how fast the "seeking" rate of Solaris is, or how fast Solaris can get information about files with the "find" command. Does anyone know what 'find' command I could run to traverse through my system to see the rate... (1 Reply)
Discussion started by: bstring
1 Replies

6. UNIX for Dummies Questions & Answers

"-maxdepth 1" argument for Solaris find. Other way to restrict find in only one directory?

Hi I wish to find only files in dir /srv/container/content/imz06/. It means exclude subfolder /srv/container/content/imz06/archive/ > uname -a SunOS testbox6 5.10 Generic_139555-08 sun4v sparc SUNW,Sun-Blade-T6320Its Solaris default "find" > find /srv/container/content/imz06/* -name... (4 Replies)
Discussion started by: slashdotweenie
4 Replies

7. AIX

maxdepth in avaible for AIX?

Hi, I'm trying to do a search in a directory on AIX and I was wondering if there's an equivelant option to the -maxdepth option to tell how far down to search. I ran this but I just want to make sure it's actually searching everything: find ./* -type f -name "090817*" -exec ls -l {} \; (1 Reply)
Discussion started by: bbbngowc
1 Replies

8. UNIX for Dummies Questions & Answers

Using find on solaris

Hello, I have searched the forum but I can't find any compliant answer to my problem. I have to list all directories on a filesystem on a solaris 5.9 up to 4th level, but it seems there's no -level or -maxdepth option. I tried to xargs or -exec the result of the find command by testing the NF... (2 Replies)
Discussion started by: davchris
2 Replies
Login or Register to Ask a Question