- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Rm commands in HP-UX
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
07-02-2004 04:54 AM
07-02-2004 04:54 AM
Rm commands in HP-UX
May i know how to remove files on a specific date? For example, i want to remove all the files in the directory that is dated 2 July. What is the command to used?
Becos i found out that when i do a ls on the root directory. I saw quite a number of garbage files on that directory on that specific date. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 05:08 AM
07-02-2004 05:08 AM
Re: Rm commands in HP-UX
For one thing, the dates you're probably seeing with the ls command are modification times, and depending on how your system has been managed in the past, up to this time, there could well be legitimate, necessary files in root dir with modification times the same as any "garbage" files.
Start with reading the man page for the rm command. The probably, if you're sure you want to remove some files, remove each of them individually. Single commands to do a lot of things are nice, elegant, but brute force has its place, and this may be one of them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 05:10 AM
07-02-2004 05:10 AM
Re: Rm commands in HP-UX
You could use the find and touch commands thusly:
touch 20040701 ref_file1
touch 20040703 ref_file2
find /start_dir -newer ref_file1 ! -newer ref_file2 -exec rm {} \;
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 05:17 AM
07-02-2004 05:17 AM
Re: Rm commands in HP-UX
First create a pair of reference files that will store you modification time ranges (the first and last seconds of 2-Jul-2004):
touch -t 200407020000.00 /var/tmp/file1
touch -t 200407022359.59 /var/tmp/file2
Now we want to remove all regular files newer than file1 and not newer than file2.
cd to desired directory
find . -type f \( -newer /var/tmp/file1 -a ! -newer /var/tmp/file2 \) -exec rm {} \;
Man touch and find for details. I would first test this with a "safe" command like "-exec ls -l {} \;" in lieu of the "-exec rm {} \;".
You could also simply use the -mtime find option as well but this is a more general technique.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 05:33 AM
07-02-2004 05:33 AM
Re: Rm commands in HP-UX
This command are useful to delete the file that creates within 24 hours.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 05:38 AM
07-02-2004 05:38 AM
Re: Rm commands in HP-UX
My suggestion when workingn with RM is to make a dir under your home directory for testing...
cd ~myhome
mkdir test
cd test
Then make some files and modify the date stamps and play with it there before you do it live...
also the use of a reference file is a very good idea... I have used that to perform tar backups of data when the time matters, say after a recent backup but you want to do work and need to make sure that ALL data is backed up and is absolutely current since the last automated backup.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 05:39 AM
07-02-2004 05:39 AM
Re: Rm commands in HP-UX
- John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 06:10 AM
07-02-2004 06:10 AM
Re: Rm commands in HP-UX
If you'll notice both Pete's and Clay's find command, you will see that neither of them says to start the find in the / directory. Pete says so do 'find /startdir' and Clay says to do 'find .'. With Clay's command you are starting from whatever directory you are in. If you happen to be in /, then yes that could be a problem. With Pete's command it will only be a problem if you specify the wrong directory.
Yes, it could be a hard lesson if there were critical files modified on July 2.
My recommendation would be to execute each of their commands first with an 'll -d' rather than the 'rm' in the exec portion of the find command. That way you can see exactly what you are going to rm.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 06:18 AM
07-02-2004 06:18 AM
Re: Rm commands in HP-UX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 06:22 AM
07-02-2004 06:22 AM
Re: Rm commands in HP-UX
That's why I recommend first substituting 'll -d' for rm in the find command.
This can also be a good lesson in being VERY VERY careful about what you do where on a unix machine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 01:51 PM
07-02-2004 01:51 PM
Re: Rm commands in HP-UX
Btw, how to check for the version of the OS i am in. Mine is HP UX 11.0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 02:56 PM
07-02-2004 02:56 PM
Re: Rm commands in HP-UX
# uname -a
Look for the string like B.11.11 or something similar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2004 03:50 PM
07-02-2004 03:50 PM
Re: Rm commands in HP-UX
All experts gave their response.
1. File removal.
================
Create the two files to indicate the end of july 1 and starting of july2 with touch command.
File's time may be differed with creation time, access time or modified time.
find
It will check only the files not directory or char or device files. If you want to remove only in one directory,use the ll with awk command as
rm -f `ll | awk '{
if ($6=="Jun")
if ($7==18)
printf "%s ",$9
}'`
2. O/S version check:
=====================
uname -v it will give the o/s version.
We can get the system informations with uname -a option.
Regards,
Muthukumar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2004 01:26 AM
07-06-2004 01:26 AM
Re: Rm commands in HP-UX
1.) Copy the directory off to tape. (First of computer science -- Never do anything you can't undo)
2.) Create a directory called trash or any other meaningful name.
3.) use any of the search techniques to identify the files.
example ll *|awk '{if (($6=='Jul')&&($7==2)){printf "mv %s trash/ \n"}}'>clean_up
4.) chmod +x clean_up
5. ./clean_up
The result is that the files are moved into the trash directory.
Now, look at the trash directory _very_ _very_ closely. Are you absolutely positively sure that you want to remove those files?
If no, put the ones you want to keep back on the source directory.
If yes, do a a ls on the current directory.
Does it list the files you really really want to delete?
Are you really really sure?
BTW rm -i is usually a good way unless there are hundreds of files.
Then use the rm command. Just know that once a file in UNIX is gone, it is really gone.
Unless your are a spy agency chances are pretty good that it will not come back.
cd out of the trash directory and remove it
cd ../
rmdir trash
--Good Luck be careful
No warranty is expressed or implied.