- Community Home
- >
- Servers and Operating Systems
- >
- Legacy
- >
- Operating System - Tru64 Unix
- >
- 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
Discussions
Discussions
Forums
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
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 .... :)