- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to do this find command?
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-2003 09:41 AM
06-09-2003 09:41 AM
-I want it to /test/aoi/inspire/defects/812165000/E02 and look for any directories under here that are more than 30 days old and if it finds them, prompts for a delete.
I can do it for files, not for directories.
Please help soon, I need it today.
Thx..Angie
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:43 AM
06-09-2003 09:43 AM
Re: How to do this find command?
There are many many 812* directories. So I need to be able to go down into the E02 and E03..E04.. E05..E06 directory, check under each of those and find if there is a directory more than 30 days old. If it then finds it, prompt for delete.
So I need to go through lots of 812* directories and lower to do the check.
Thx..Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:47 AM
06-09-2003 09:47 AM
Re: How to do this find command?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:50 AM
06-09-2003 09:50 AM
Re: How to do this find command?
Here is one way to try it:
find /test/aoi/inspire/defects/812* -type d -mtime +30 -depth -ok rm -rf {} \;
I would suggest testing it first by replacing the 'rm -rf' with something like an 'ls -ld' to make sure it is returning the correct directories.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:50 AM
06-09-2003 09:50 AM
Re: How to do this find command?
So would either of those find commands go underneath the 812* part, then go underneath each of the directories under there? Example, 812165000 may have E01, E02, E03...E20 and I would need to do the actual check on each directory under each E01, E02, E03... etc.
Please respond.
Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:53 AM
06-09-2003 09:53 AM
Re: How to do this find command?
Sorry, I left out the mtime part!
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:54 AM
06-09-2003 09:54 AM
Re: How to do this find command?
Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:55 AM
06-09-2003 09:55 AM
Re: How to do this find command?
One thing to consider is that removing a file from a directory will change the modified date of the directory, so the counter will reset. You might want to run the find without trying to remove the directories first, store the information in a file, and then try to remove the directories.
Brian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:55 AM
06-09-2003 09:55 AM
Re: How to do this find command?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 09:56 AM
06-09-2003 09:56 AM
Re: How to do this find command?
# find dir_path -type d -depth -xdev \( -atime +30 -a -mtime +30 \) -exec rm -ir {} \;
This will check each directories and will prompt for delete if not accessed or modified within last 30 days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 11:31 AM
06-09-2003 11:31 AM
Re: How to do this find command?
'find' on a directory will change it's "atime" immediately, so I guess the command you gave won't yield any result.
thanks,
Gary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 12:56 PM
06-09-2003 12:56 PM
Re: How to do this find command?
find /tmp/811* -type d -mtime +30 -depth -ok ls -ld {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 01:12 PM
06-09-2003 01:12 PM
Re: How to do this find command?
What error message are you getting when you try the command? Do you have some 811* directories in /tmp? You might have to enclose the '/tmp/811*' in single quotes.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 01:17 PM
06-09-2003 01:17 PM
Re: How to do this find command?
#!/bin/sh
##########
CACHE=/tmp/.doIdelete
if [ -f "${CACHE}" ] ; then
rm -f $CACHE
fi
touch $CACHE
find /test/aoi/inspire/defects -type d -name "812*" -atime +30 -print 1>>$CACHE 2>>/dev/null
# At this point, look at your file.
# If it's empty, then nothing is older
# than 30 days. Change the number to
# ensure that your seeing output
# If you have output, add this
for DIR in `cat ${CACHE}` ; do
echo "Delete $DIR? Y/N"
read INPUT
case $INPUT in
y*|Y*) rm -fr $DIR
echo "$DIR is gone"
;;
n*|N*) echo "Not touching it"
esac
done
This will make a nice loop, and give you a chance to see what is going on. While find is good by itself, most of us want to "Know" that it's working like we want.
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 01:20 PM
06-09-2003 01:20 PM
Re: How to do this find command?
The whole case should be...
case $INPUT in
y*|Y*) rm -fr $DIR
echo "$DIR is gone"
;;
n*|N*) echo "Not touching it"
;;
esac
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 01:26 PM
06-09-2003 01:26 PM
Re: How to do this find command?
I don't understand the Case statements very well. I was trying to avoid that and just use the find command.
Can it be done?
Angie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 01:37 PM
06-09-2003 01:37 PM
Re: How to do this find command?
If you are 100% sure you can delete the directory then avoid the part that prompt you for an answer. In that case, just try Pete's recommendation. Otherwise you will have to use a case statement.
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 01:45 PM
06-09-2003 01:45 PM
Re: How to do this find command?
I used Pete's answer as an example, Paul and John's will work too. I did not want to leave them behind.
Regards,
DR
NO POINTS PLEASE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 01:45 PM
06-09-2003 01:45 PM
Re: How to do this find command?
case $VARIABLE in
something) "exec this"
;; #ends something
nextthing) "exec this"
;;
esac
All I did was used the "read" command to get input from the user. I used y*|Y*) so that if anything beginning with "y" or "Y" is typed in, it's accepted to delete. Meaning someone types "yes" instead of just "y" then enter. Yes, you can use wildcards as well as "|" piped strings to look for in the case.
I think if you type it in just how I have it, it should work.
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2003 01:47 PM
06-09-2003 01:47 PM
Re: How to do this find command?
Thanks a ton everyone!!!
I owe some points!!! And will assign them.
Thanks,
Angie