- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Operating System - Tru64 Unix
- >
- Re: FIND command..stop it from processing sub-dirs
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
06-09-2008 02:26 AM
06-09-2008 02:26 AM
I need to find files in
/loc/A greater than a specific date
to /loc/A/archive
This is my test:
-----------------------
1. Touched a reference file
touch -t 200806030000 /tmp/june3.ref
2. Verify (without moving files) that the find command finds files older than June 3rd (Use ! operator with -newer option)
find /loc/A ! -newer /tmp/june3.ref -type f -exec ls -l {} \;
Result:
--------------------------
Lists files older than June 3rd ok.
But descends into /loc/A/archive which is where I want move the files I find from /loc/A.
So this will be a loop. I need to stop the find command from processing files in sub-directories.
I could script this but if there's a way to tell "find" to process the current directory only that would be great.
Cheers
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 02:54 AM
06-09-2008 02:54 AM
Re: FIND command..stop it from processing sub-dirs
find /loc/A ! -newer /tmp/june3.ref -type f -o ! -name A -prune ! -type d
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 02:56 AM
06-09-2008 02:56 AM
Re: FIND command..stop it from processing sub-dirs
Don't know if this matters but I'm running this on HP Tru64.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 02:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 03:01 AM
06-09-2008 03:01 AM
Re: FIND command..stop it from processing sub-dirs
My final command
find . ! -newer /tmp/june3.ref \( -type f -o ! -name A -prune ! -type d \) -exec ls -l {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 03:07 AM
06-09-2008 03:07 AM
Re: FIND command..stop it from processing sub-dirs
My final command was
find . ! -newer /tmp/june3.ref \( -type f -o -prune ! -type d \) -exec ls -l {} \;
Took out the ! -name A
Still worked the same as with it in.
Laurent what was the purpose of the ! -name A portion of the command....is it a mistake to leave it out?
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 03:18 AM
06-09-2008 03:18 AM
Re: FIND command..stop it from processing sub-dirs
It skips the directory/file "A". But "-type f" also skips it.
You might also use ! -path "./A/*", but -prune may stop earlier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 03:37 AM
06-09-2008 03:37 AM
Re: FIND command..stop it from processing sub-dirs
When I closed the thread my output didn't include any of the sub-dirs.
Now it does. gone through my history of commands to see if I did anything different and no luck.
Tried the ! -path option as well without success.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 03:48 AM
06-09-2008 03:48 AM
Re: FIND command..stop it from processing sub-dirs
Use the '-path option' like this:
# find /loc/A -type f ! -path "/loca/A/archive/*" ! -newer /tmp/june3.ref ! -exec ls -l {} \+
I reordered the options a bit to discard non-matches a bit earlier (hopefully). That aside, note the use of the *quoted* '-path' argument so that the shell doesn't expand the "*". Notice too, the faster form of '-ecec' using the "+" terminator to spawn a process with multiple arguments instead of one per argument.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 03:54 AM
06-09-2008 03:54 AM
Re: FIND command..stop it from processing sub-dirs
I'm slowly building the command up. I can list files in the directory now without the subdirs
EXAMPLE 1 - which does show files in subdirs
> find /tmp/A/*
/tmp/A/B
/tmp/A/B/test2.txt
/tmp/A/test1.txt
EXAMPLE 2 - Dies not show subdirs
root > find /tmp/A/* -prune ! -type d
/tmp/A/test1.txt
Now just have to get the condition in for files older than June 3.
Stay tuned .... :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 04:01 AM
06-09-2008 04:01 AM
Re: FIND command..stop it from processing sub-dirs
root > find /loc/A/* -prune ! -type d ! -newer /tmp/june3.ref -exec ls {} \;
I put the /* after the pathname
And reorderd the options.
Here are 3 lines of the output. But I had hundreds of lines and none (verified with grep) had files in any subdirectories.
/loc/A/54482.log
/loc/A/54484.lis
/loc/A/54484.log
Anyone see any potential flaws with this?
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 04:01 AM
06-09-2008 04:01 AM
Re: FIND command..stop it from processing sub-dirs
> Thanks James but the -path option doesn't appear to be valid for Tru64.
Well, this is the *HP-UX* formum! You should have posted this in the Tru64 UNIX family:
http://forums11.itrc.hp.com/service/forums/familyhome.do?familyId=280
You can ask to have it moved, here:
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1236703
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 04:06 AM
06-09-2008 04:06 AM
Re: FIND command..stop it from processing sub-dirs
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2008 04:22 AM
06-09-2008 04:22 AM
Re: FIND command..stop it from processing sub-dirs
because you made the following request:
find /loc/A ! -newer /tmp/june3.ref -type f -exec ls -l {} \;
If you avoid all what I made the first directory encountered is A; so the -prune avoid to continue. and it will display nothing
When you make it from . it is different as we are already in the current directory, so - prune don't cut the display.
Why I didn't use find /loc/A/* -prune ! -type d ! -newer /tmp/june3.ref -exec ls {} \;
because if I have hidden files begining with a "." then they will not be seen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2008 11:08 PM
07-03-2008 11:08 PM
Re: FIND command..stop it from processing sub-dirs
Thanks for the help.
I got onto other things. I'll post what I did once I find that darn command I used.