Help with the find cmd


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with the find cmd
# 8  
Old 07-11-2012
Quote:
Originally Posted by bitlord
[URL="https://www.unix.com/members/32659.html"][COLOR=#9F0505]alister,
Your examples didn't work on Solaris but worked on RHEL.
Code:
find / -type f -name java -print -o \( -path /tmp -prune \)

I got this error in Solaris
Code:
find: bad option -path
find: path-list predicate-list

Thanks for the help everyone. Sorry I was so late getting back to you, sooner, I had to step away from my desk.
First and foremost, how dare you step away from your desk when there's unix.com business pending? Smilie

I do not present the following in an attempt to sway you away from the grep solution that is already working for you. I'm merely posting it to show another way to work around the unavailability of the -path predicate. It should work on Solaris, although I do not have any experience with that platform (unless you count those 5 minutes, a few years ago, that I spent poking around in an OpenSolaris LiveCD environment):

Code:
find / -type f -name java -print -o \( -name tmp -type d -exec test {} = /tmp \; -prune \)

The use of -name (with the basename of the directory) and -type predicates is not strictly necessary; they do not in any way affect the output of the command. They are there only as a performance optimization, preventing -exec from forking when the test cannot possibly succeed (-name) or when the test is not necessary (-type).

At this point, the readability gap between the all find approach and the grep pipeline has widened. However, in situations where very large subtrees are to be excluded and where resources may be at a premium, an advantage of the find solution's -prune is that it avoids visiting very many files that are of no interest. With the grep solution, find has to visit all the unwanted files and directories since it is grep that will determine what to include. However, in your case, this may not be an issue at all.

Regards,
Alister

Last edited by alister; 07-11-2012 at 09:00 PM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Find cmd and sym links

Hi. Can somebody tell me if there's a way of creating a symbolic link from a directory on one filesystem to that on another that will allow a find command that doesn't use the -L param to locate a particular file under that new 'linked' dir. With a normal sym link the find command on that... (6 Replies)
Discussion started by: user052009
6 Replies

2. Shell Programming and Scripting

Nested find cmd

Hi gurus, greetings. Objective: find in a path directories that are named Logs. In each found Logs dir search for files with .log extension and remove -atime +6. (Note for test/example, rm and -atime is not used). Issue: If I execute the script without redirecting output to a file, on... (8 Replies)
Discussion started by: rsheikh
8 Replies

3. Shell Programming and Scripting

find cmd works different on cron job ?

/usr/bin/find $SEARCH_DIR -daystart \( \( -name 'KI*' -a -name '*.csv' \) -o -name '*_xyz_*' \) -mtime $DAYS_AGO -printf %f -printf "\n" | sort -r > $FILES The above command gives different results when run on a cron job. When run manually the result is accurate. (2 Replies)
Discussion started by: nuthalapati
2 Replies

4. Shell Programming and Scripting

How to link lsof and find cmd?

Hi All, My target is to find the biggest files opened by any process and from that i have to find process id and the corresponding file also to avoid file system being hung-up. Finding the process id: is to kill the process Finding the biggest file: is to remove the file To get the process... (0 Replies)
Discussion started by: Arunprasad
0 Replies

5. Shell Programming and Scripting

date with find cmd

Hi for today i have 10 files, in that i need search some values how can i write a find cmd with perticular date thanks SAIC (4 Replies)
Discussion started by: saic
4 Replies

6. Shell Programming and Scripting

Find cmd not working correctly in script

I am trying to copy 2 types of files so I can archive them. I tested with a set of commands: touch -t $(date -d "-60 day" +%Y%m%d) WORKDIR/REF find TARGETDIR/ -type f -maxdepth 1 -iname \*.out\* -or -iname \*.log\* ! -newer WORKDIR/REF -exec ls -l {} \; This correctly lists any files in the... (2 Replies)
Discussion started by: prismtx
2 Replies

7. Shell Programming and Scripting

how to find status of last executed cmd in perl?

In shell we can find the status of last executed command by $? In perl what is the command to find the status of last executed command... Can any one please say??????????????? Thanks, Prabhu (1 Reply)
Discussion started by: prsampath
1 Replies

8. Shell Programming and Scripting

using find cmd to find certain files

i have a list of files below: rwxrwxrwx 1 pipe pipe 180 Mar 4 22:47 del_0n_Date -rwxrwxrwx 1 pipe pipe 472 Mar 4 22:58 mail_Check -rw-r--r-- 1 pipe pipe 92 Mar 4 22:58 minfo.txt -rwxrwxrwx 1 pipe pipe 609 Mar 5 05:12... (6 Replies)
Discussion started by: ali560045
6 Replies

9. Solaris

Find cmd working in Linux and not in SunSolaris 5.8

find . -type f -mtime -1 -ls command not working in sun solaris 5.8 (4 Replies)
Discussion started by: navjotbaweja
4 Replies

10. Shell Programming and Scripting

Find cmd not working as expected

Hi, i wan to search the file starting with Admin into the directory Output. I am running below command: find /appl/Output -name "Admin*" -prune but this command is going into the sub directories present under output. I do not want to search under sub directories. Any help will be highly... (6 Replies)
Discussion started by: Vishal123
6 Replies
Login or Register to Ask a Question