Sponsored Content
Operating Systems Solaris correct usage of find's -prune option Post 302311739 by ProGrammar on Wednesday 29th of April 2009 11:35:19 AM
Old 04-29-2009
Oh my lawd!!

Quote:
Originally Posted by pludi
Don't worry, I think everyone stumbles on this "bug" sooner or later.
-prune tells find to only look at the directories specified at the command line, in your case your current working directory, and nothing else. If you run it as
Code:
# find ./* -type -d -prune

it will check the contents of the current directory (and nothing below)

So I fell out of my chair when I realized how ./* made the world of difference. By the way, this performed exactly what I originally intended. Pludi, YOU'RE THE MAN!! Anybody who tells you otherwise probably has parents who are brother and sister. Smilie

I do have a question for you though...

I understand that sh evaluates ./* to mean everything below the current working directory, but I would naturally assume (.) to include the same. So where did I go wrong? Can you understand the error in my comprehension? Iunno--I guess that's just the way I understood the man page.

Radoulov,

you gave some very good solutions too, namely the option negating anything named . (! -name .). Thanks!

I don't have maxdepth option, I have whichever version of find ships with Solaris 9.x
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

finding files using prune option

Hi All, I am trying to find files in a directory and don't want to search in the sub directories and using the command find . \( ! -name . -prune \) -mtime +1 -name '*.log' and is working fine. But when I am trying with absolute path then is not working like find /home/subodh \( ! -name... (1 Reply)
Discussion started by: subodh.sharma
1 Replies

2. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

3. Linux

doubt in -prune option

i want to find only the file t4 in directory t3. i am in dir t . the tree is as follows. if i give, find . o/p is . ./t4 ./t1 ./t1/t2 ./t1/t2/t3 ./t1/t2/t3/t4 ./t1/t2/t4 ./t1/t4 directories are like t/t1/t2/t3 and each directory has file t4. my question is , i want to find file... (0 Replies)
Discussion started by: bhuvaneshlal
0 Replies

4. UNIX for Dummies Questions & Answers

help me out with find command , -prune option

Hi , Kindly help me out .:) i want to find only the file t4 in directory t3. i am in dir t . the tree is as follows. if i give, find . o/p is . ./t4 ./t1 ./t1/t2 ./t1/t2/t3 ./t1/t2/t3/t4 ./t1/t2/t4 ./t1/t4 directories are like t/t1/t2/t3 and each directory has file t4. my... (7 Replies)
Discussion started by: bhuvaneshlal
7 Replies

5. Shell Programming and Scripting

find with prune option

Hi, I want to list files only from the current dir and its child dir (not from child's child dir). i have the following files, ./ABC/1.log ./ABC/2.log ./ABC/ABC1/A.log ./ABC/ABC1/B.log ./ABC/ABC1/XYZ/A1.log ./ABC/ABC1/XYZ/A2.log Here i want to list only the log file from current... (1 Reply)
Discussion started by: apsprabhu
1 Replies

6. Shell Programming and Scripting

help with find command and prune option

Hi I have a directory say mydir and inside it there are many files and subdirectories and also a directory called lost+found owned by root user I want to print all files directories and subdirectorres from my directory using find command except lost+found If i do find . \( -name... (3 Replies)
Discussion started by: xiamin
3 Replies

7. UNIX for Dummies Questions & Answers

AIX find command using prune option

Hi, I am trying to find some files in a directory and then remove/list them if they are 30 days old. I also have 2 directories in that directory which I need to skip. Can someone please tell me what is the correct syntax? find /developer/. -name "lost+found" "projects" -prune -o -type f... (2 Replies)
Discussion started by: tkhan9
2 Replies

8. UNIX for Dummies Questions & Answers

find with prune option help needed

Hello, I am using ksh93 (/usr/dt/bin/dtksh) on Solaris and am stuck when trying to use find with the -prune option. I need to search a directory (supplied in a variable) for files matching a certain pattern, but ignore any sub-directories. I have tried: find ${full_path_to_dir_to_search}... (9 Replies)
Discussion started by: gary_w
9 Replies

9. Solaris

Usage of -prune and -name in find

I am into cd /home/work/amey/history-*/ Under amey I have directories history, history-1, history-2 and under history-2 I have got 2 files 3 and 2. When I run the find command I get the below o/p. find /home/work/amey/history-*/. -name . -o -prune -type f /home/work/amey/history-1/.... (1 Reply)
Discussion started by: ameyrk
1 Replies

10. UNIX for Beginners Questions & Answers

Prune Option for Find Command on AIX

I need to delete all files from the working directory and its sub directories using the find command, for that I am using -prune option but some how I am having a syntax issue. I have tried the below, please help me correct the syntax find . -name \* -type f -exec rm -f {} \; >> Works but... (4 Replies)
Discussion started by: rosebud123
4 Replies
PWD(1)							    BSD General Commands Manual 						    PWD(1)

NAME
pwd -- return working directory name SYNOPSIS
pwd [-LP] DESCRIPTION
The pwd utility writes the absolute pathname of the current working directory to the standard output. Some shells may provide a builtin pwd command which is similar or identical to this utility. Consult the builtin(1) manual page. The options are as follows: -L Display the logical current working directory. -P Display the physical current working directory (all symbolic links resolved). If no options are specified, the -P option is assumed. ENVIRONMENT
Environment variables used by pwd: PWD Logical current working directory. DIAGNOSTICS
The pwd utility exits 0 on success, and >0 if an error occurs. STANDARDS
The pwd utility conforms to IEEE Std 1003.1-2001 (``POSIX.1''). SEE ALSO
builtin(1), cd(1), csh(1), sh(1), getcwd(3) BUGS
In csh(1) the command dirs is always faster because it is built into that shell. However, it can give a different answer in the rare case that the current directory or a containing directory was moved after the shell descended into it. The -L option does not work unless the PWD environment variable is exported by the shell. BSD
February 4, 2002 BSD
All times are GMT -4. The time now is 04:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy