|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with the find cmd
Hello, I'm having a trouble with the find cmd. I would like to find all the java versions on my systems. I have solaris 9 & 10 RHEL and SUSIE. Code:
java -version doesn't give all the versions on the server. So I am trying to use the find command to find them all Code:
find / -name java I would like to exclude some directories such as Solaris zones, /tmp and mounted files systems. I don't need directories, I just what the files. Can someone help me out? |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
To find just regular files: Code:
find / -name java -type f |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks for the info.
I tried the command you gave me and it worked great. Is there a way though to exclude a directory, like for example /export/zones? |
|
#4
|
|||
|
|||
|
two ways: Code:
find / -name java -type f | grep -v '^/export/zones' # another way find / \( -name java -a ! -name '/export/zones/*' \) -type f I prefer the grep approach. |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Quote:
It looks to me as though your find command won't work. The -name primary only handles basenames. There will never be a forward slash in a basename so ! -name '/export/zones/*' will always evaluate true. The following should do it (untested): Code:
find / -type f -name java -print -o \( -path /export/zones -prune \) Regards, Alister ---------- Post updated at 02:12 PM ---------- Previous update was at 02:07 PM ---------- Quote:
Code:
find / -type f -name java -print \
-o \( -path /dir1 -prune \) \
-o \( -path /dir2 -prune \) \
-o \( -path /dir3 -prune \) \
...
-o \( -path /dirN -prune \)Regards, Alister |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
All those -o's is also why I prefer the grep (-E) option
![]() |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
jim mcnamara, I was able to get your example to work on both Solaris and RHEL,thanks. Code:
find / -name java -type f | grep -v '^/export/zones' 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. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Find Failing on directory with spaces in directory name Find xargs sed errors. Find and replace. | sipeki | UNIX for Dummies Questions & Answers | 28 | 04-08-2012 05:35 PM |
| find: missing argument to `-exec' while redirecting using find in perl | ramkumarselvam | Shell Programming and Scripting | 2 | 12-16-2011 06:48 PM |
| Simplified find command to find multiple file types | vickramshetty | Linux | 2 | 05-28-2010 01:28 PM |
| how to find a file named vijay in a directory using find command | amirthraj_12 | UNIX for Dummies Questions & Answers | 6 | 10-25-2008 12:37 PM |
| command find returned bash: /usr/bin/find: Argument list too long | yacsil | Shell Programming and Scripting | 1 | 12-15-2003 05:38 PM |
|
|