- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Using the Find command to Exclude several Director...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 08:47 AM
11-01-2002 08:47 AM
Using the Find command to Exclude several Directories
I am trying to use the find command to make some system backups.
I have an Network File system on the drive, and several other directories that I don't want to backup.
I am using HP-UX 9.03 (yeah, yeah, I know...)
The first thing I'm trying to do is just write all of the file names to a file to make sure I'm getting the correct ones, but it isn't working.
The driectories I'm trying to exclude are:
/PE-WRKST
/users/hp4062/measure
/users/hp4062/PPG
/users/hp4062/ON_LINE
/users/hp4062/OFF_LINE
Here is the command I was trying to use:
find . \! \( -path /PE-WRKST -o -path /users/hp4062/measure -o -path /users/hp4062/PPG -o -path /users/hp4062/ON_LINE -o -path /users/hp4062/OFF_LINE \) -print > /users/hp4062/temp/BackTest
I'm not quite sure why I keep getting the excluded directories in my file?
Am I using the -o wrong?
Do I need to Exclude each of the arguments?
Regards,
Jeremy Foland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 09:01 AM
11-01-2002 09:01 AM
Re: Using the Find command to Exclude several Directories
l1:/u/usr/merijn 102 > nfind --help
Usage: nfind [path...] [expression]
default path is the current directory; default expression is -print
expression may consist of:
operators (decreasing precedence; -and is implicit where no others are given):
( EXPR ) ! EXPR -not EXPR EXPR1 -a EXPR2 EXPR1 -and EXPR2
EXPR1 -o EXPR2 EXPR1 -or EXPR2 EXPR1 , EXPR2
options (always true): -daystart -depth -follow --help
-maxdepth LEVELS -mindepth LEVELS -mount -noleaf --version -xdev
tests (N can be +N or -N or N): -amin N -anewer FILE -atime N -cmin N
-cnewer FILE -ctime N -empty -false -fstype TYPE -gid N -group NAME
-ilname PATTERN -iname PATTERN -inum N -ipath PATTERN -iregex PATTERN
-links N -lname PATTERN -mmin N -mtime N -name PATTERN -newer FILE
-nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN
-size N[bckw] -true -type [bcdpfls] -uid N -used N -user NAME
-xtype [bcdpfls]
actions: -exec COMMAND ; -fprint FILE -fprint0 FILE -fprintf FILE FORMAT
-ok COMMAND ; -print -print0 -printf FORMAT -prune -ls
l1:/u/usr/merijn 103 >
Or you can use perl
# perl -MFile::Find -le 'find(sub{m,^\./(PE-WRKST|users/hp4062/(measure|PPG|ON_LINE))\b,&&return;print$File::Find::name},".")'
But you can also change your own command:
find . | egrep -v -e ^./PE-WRKST -e '^./users/hp4062/(measure|PPG|ON_LINE)' > /users/hp4062/temp/BackTest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 09:03 AM
11-01-2002 09:03 AM
Re: Using the Find command to Exclude several Directories
find . ! \( -path '/users/hp4062/PPG' - '/users/hp4062/PPG/*' \) -print
to exclude the PPG directory and any files beneath it. Note the use of single quotes. We do not want the shell to expand the *'s.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 10:00 AM
11-01-2002 10:00 AM
Re: Using the Find command to Exclude several Directories
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 10:02 AM
11-01-2002 10:02 AM
Re: Using the Find command to Exclude several Directories
procura - Unfortunately on my ancient relic of a HP-UX system, the nfind and perl commands are unavailable. Thanks anyways.
A. Clay Stephenson ,
Can you explain the minus in the middle of the two single quoted expressions. I don't understand why both expressions are needed. Can you explain a bit more?
find . ! \( -path '/users/hp4062/PPG' - '/users/hp4062/PPG/*' \) -print
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 11:44 AM
11-01-2002 11:44 AM
Re: Using the Find command to Exclude several Directories
find . ! \( -path '/PE-WRKST' -o -path '/users/hp4062/measure' -o -path '/users/hp4062/PPG' -o -path '/users/hp4062/ON_LINE' -o -path '/users/hp4062/OFF_LINE' -path '/PE-WRKST/*' -o -path '/users/hp4062/measure/*' -o -path '/users/hp4062/PPG/*' -o -path '/users/hp4062/ON_LINE/*' -o -path '/users/hp4062/OFF_LINE/*' \) -print > /users/hp4062/temp/BackTest
I also tried it with a \! instead.
now I'm trying switching to csh first, and trying the above. I keep getting those directories included.
What about
find . \( -path '/PE-WRKST' -o -path '/users/hp4062/measure' -o -path '/users/hp4062/PPG' -o -path '/users/hp4062/ON_LINE' -o -path '/users/hp4062/OFF_LINE' -path '/PE-WRKST/*' -o -path '/users/hp4062/measure/*' -o -path '/users/hp4062/PPG/*' -o -path '/users/hp4062/ON_LINE/*' -o -path '/users/hp4062/OFF_LINE/*' \)-o -print > /users/hp4062/temp/BackTest
Will that work?
Jeremy Foland
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 12:03 PM
11-01-2002 12:03 PM
Re: Using the Find command to Exclude several Directories
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2002 12:25 PM
11-01-2002 12:25 PM
Re: Using the Find command to Exclude several Directories
The main point is that you need to specify the directory
-path /mydir and any files and subdirs below it -path '/mydir/*'. You might be tempted to specify them both is one shot as '/mydir*' BUT that would exclude '/mydir2' - something you probably did not intend.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2002 11:06 AM
11-02-2002 11:06 AM
Re: Using the Find command to Exclude several Directories
in your last example, there doesn't seem a need for the
\(
or the closing \)
and the
-o
after the \)
Nor, is there a need to use apostrophes (').
Is this still an issue?
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2002 08:33 AM
11-03-2002 08:33 AM
Re: Using the Find command to Exclude several Directories
find /tmp | grep /tmp/tmp
/tmp/tmp
/tmp/tmp/a b
/tmp/tmp/l1
find /tmp ! \( -path /tmp/tmp \) | grep /tmp/tmp
/tmp/tmp/a b
/tmp/tmp/l1
find /tmp ! \( -path '/tmp/tmp/*' \) | grep /tmp/tmp
/tmp/tmp
and, finally,
find /tmp ! \( -path /tmp/tmp -o -path '/tmp/tmp/*' \) | grep /tmp/tmp
Also, you *definitely* want to use single quotes around any -path arguments that contain wildcard characters.
Otherwise,
find /tmp ! \( -path /tmp/tmp/* \)
would be interpreted by the shell, before passing it to 'find', as:
find /tmp ! \( -path /tmp/tmp/a b /tmp/tmp/l1 \)
which 'find' would choke on:
find: bad option /tmp/tmp/a
You *can* sometimes get by with wildcards and the -name keyword, if you know that no names in your current directory match the -name wildcard argument.
And, yes, removing the "!" and adding the "-o -print" will work, as well.
bv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2002 05:06 AM
11-04-2002 05:06 AM
Re: Using the Find command to Exclude several Directories
find . -print | egrep -v 'PE-WRKST|users/hp4062/measure|users/hp4062/PPG|users/hp4062/ON_LINE|users/hp4062/OFFLINE' > /users/hp4062/temp/BackTest
The | symbol is the PIPE symbol, on a PC keyboard this is SHIFT+\.
If you wanted to send it to a tape drive instead, just remove the '> /users/hp4062/temp/BackTest' and put '| tar cvf /dev/rmt/0m'.
You do not have to put the leading / in the any of the excluded directories as the 'find .' does not contain them in its listings.
I hope this is of help to you.
Many thanks, Graeme.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2002 05:19 AM
11-04-2002 05:19 AM
Re: Using the Find command to Exclude several Directories
I neither can help you with a 9.0x port for perl. We don't have 9.0x anymore, but I guess you can still find a rather old version (4.036) of perl on /usr/contrib/bin, which won't recognize the -M option
What was wrong with the (e)grep solution?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2002 01:20 PM
11-04-2002 01:20 PM
Re: Using the Find command to Exclude several Directories
I hadn't tried the egrep earlier because I was unfamiliar with it. I tried it earlier today and it seems to work. Thanks.
Can you tell me what the -e option is. That was some pretty fancy use of character matching symbols, but I think I figured it out.
Thanks.
Jeremy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2002 02:55 PM
11-05-2002 02:55 PM
Re: Using the Find command to Exclude several Directories
Can I cpio -p to a directory on an NFS?
It keeps saying cannot write on /PE-WRKST/hp4062-2
Regards,
Jeremy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2002 03:02 PM
11-05-2002 03:02 PM
Re: Using the Find command to Exclude several Directories
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2002 08:16 AM
11-06-2002 08:16 AM
Re: Using the Find command to Exclude several Directories
Thanks for all the help, everyone.