- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- "non recursive find" or "how to get the age of a f...
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
тАО07-01-2003 12:34 PM
тАО07-01-2003 12:34 PM
Does anyone knows how to convince a find command not to descend the filesystem hierarchy and search only the current directory?
The reason for that are: I need to remove a certain file just if it's more than 7 days old. The problem is that it sits on top of a very large directory structure and I can't afford to wait the find traverse the whole place before finally look around and see the file. :)
Thanks already!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2003 12:40 PM
тАО07-01-2003 12:40 PM
Re: "non recursive find" or "how to get the age of a file"
find . -name "yourfile"
or
find /yourdir -name "your file"
-USA..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2003 12:46 PM
тАО07-01-2003 12:46 PM
Re: "non recursive find" or "how to get the age of a file"
will operate only on the current directory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2003 12:46 PM
тАО07-01-2003 12:46 PM
Solutionfind . -path "./*" -prune -mtime +7 -print
The "-path" can limit the file path and "-prune" will prevent find from descending subfolders.
If you wanted to do one level down of directories-
find . -path "./*/*" -prune -mtime +7 -print
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2003 12:49 PM
тАО07-01-2003 12:49 PM
Re: "non recursive find" or "how to get the age of a file"
That was my first attempt, but when the directory where I am have several others sub-directories each one having a lot of files the find will search those sub-directories also and the search takes much more time. How could I tell find to skip all sub-directories and search just the current one?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2003 12:51 PM
тАО07-01-2003 12:51 PM
Re: "non recursive find" or "how to get the age of a file"
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2003 12:54 PM
тАО07-01-2003 12:54 PM
Re: "non recursive find" or "how to get the age of a file"
Bingo!
That's perfect!
I was really messing up with the -prune syntax.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2003 01:31 PM
тАО07-01-2003 01:31 PM
Re: "non recursive find" or "how to get the age of a file"
I believe find uses a zero based counter where 0 = 24 hours. So for seven days use 6.
-ctime +6
GNU find is superior and uses 'maxdepth'.
find /dir/sub_dir -maxdepth 0 -ctime +6 -exec rm {} \;
-atime - read or view but don't write to. (* access *)
-mtime - write to. (* modify *)
-command line level only
So toy around with atime and ctime.
Here's GNU find:
http://hpux.cs.utah.edu/hppd/hpux/Gnu/findutils-4.1.5/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2003 09:59 PM
тАО07-01-2003 09:59 PM
Re: "non recursive find" or "how to get the age of a file"
#!/bin/ksh
for i in `ls *fname*`
do
if [ -f $i ]
then
find $i -atime +7
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-23-2009 06:37 PM
тАО12-23-2009 06:37 PM