- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: find and delete files at the same time ?
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
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
тАО10-15-2000 07:57 PM
тАО10-15-2000 07:57 PM
Is there any command to find a list of files of a particular extension, then delete them?
Because my /home is full, and after my find command, I've got a long list of the different directories which contains the files with extension .out but it's too tedious for me to navigate into each and every directory from the list and remove them manually.
Please help !
# find /home/dgm -name *.out
/home/dgm/dgmsls74/DGM1039.out
/home/dgm/dgmsls74/DGM1019.out
/home/dgm/dgmsls74/DGM1030.out
/home/dgm/dgmsls74/DGM1067.out
/home/dgm/dgmsls74/DGM1003.out
/home/dgm/dgmecc03/DGM1037.out
/home/dgm/dgmecc03/DGM1030.out
/home/dgm/dgmecc03/DGM1011.out
/home/dgm/dgmecc03/DGM1100.out
/home/dgm/dgmecc03/DGM1020.out
/home/dgm/dgmecc03/DGM1007.out
/home/dgm/dgmecc03/DGM1042.out
/home/dgm/dgmecc03/DGM1061.out
/home/dgm/dgmecc03/DGM1091.out
/home/dgm/dgmecc03/DGM1063.out
/home/dgm/dgmecc03/DGM1035.out
/home/dgm/dgmecc03/DGM1044.out
/home/dgm/dgmecc03/DGM1050.out
/home/dgm/dgmecc03/DGM1064.out
/home/dgm/dgmecc03/DGM1049.out
/home/dgm/dgmecc03/DGM1096.out
/home/dgm/dgmecc03/DGM1082.out
/home/dgm/dgmecc03/DGM1047.out
(and the list goes on...)
Thanks a million !
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2000 08:54 PM
тАО10-15-2000 08:54 PM
Re: find and delete files at the same time ?
Remove all files named a.out or *.o that have not been accessed for a week:
find / ( -name a.out -o -name '*.o' ) -atime +7 -exec rm {} ;
For your problem you can try this .
find /home *.out -exec rm {} ;
good luck .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2000 09:10 PM
тАО10-15-2000 09:10 PM
Re: find and delete files at the same time ?
find /home -name '*.out' -print -exec rm -f {} ;
--- This will remove the files with extension .out under /home dir .
hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2000 09:40 PM
тАО10-15-2000 09:40 PM
Re: find and delete files at the same time ?
Thanks for your reply. I've tried both commands but failed.
I've got the following message.
# find /home *.out -exec rm {} ;
find: -exec not terminated with ';'
# find /home -name '*.out' -print -exec rm -f {} ;
find: -exec not terminated with ';'
Please advise what could have gone wrong.
Thanks !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2000 10:28 PM
тАО10-15-2000 10:28 PM
Re: find and delete files at the same time ?
The commands are rigth but you have to put the back slash before the semicolon at the end of instruction without white space.
federico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2000 10:50 PM
тАО10-15-2000 10:50 PM
Re: find and delete files at the same time ?
this should do it:
find /home -name '*.out' -print -exec rm -f {} ";"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2000 11:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2000 11:47 PM
тАО10-15-2000 11:47 PM
Re: find and delete files at the same time ?
Thanks a miilion !
10 points for you !
Thanks for the rest as well !
I've awarded points for you guys too !
Best Regards,
Shirley
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-16-2000 05:22 AM
тАО10-16-2000 05:22 AM
Re: find and delete files at the same time ?
To find certain file and then delete issue the command below:
find /home/dgm -name *.out -exec rm {} ;
Hope it's help you.
Augusto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-16-2000 06:59 AM
тАО10-16-2000 06:59 AM
Re: find and delete files at the same time ?
This find .. -exec rm construct works fine, but is pretty slow. If you have a awful lot of directories and files to scan and delete it is better to do the following.
Instead of -exec rm do a -print to a file. Then work thru the file and delete each entry. I did this in a script for "cleaning" the filesystem and reduced the time for finding and deleting by 50 %.
I dont think you will have to consider this, but just liked to tell you.
Regards
Stefan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-16-2000 07:41 AM
тАО10-16-2000 07:41 AM
Re: find and delete files at the same time ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-16-2000 08:15 AM
тАО10-16-2000 08:15 AM
Re: find and delete files at the same time ?
The correct command to do this is:
find /home/dgm -name "*.out" | xargs rm
see xargs man for explanations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-17-2000 12:59 AM
тАО10-17-2000 12:59 AM
Re: find and delete files at the same time ?
As i said if you have a lot (not just some) files to delete the xargs command doesn't help you.
But again i don't think this is a problem here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-17-2000 03:57 AM
тАО10-17-2000 03:57 AM
Re: find and delete files at the same time ?
xargs command issue read args from stdin and issues commands ( as many commands as needed) to acomplish the task.
In our example must do:
rm /home/..../f1 /home/.../f2 .... /home/.../f33
rm /home/.../34 .....
In other words, instead of do 3300 rm commands , xargs issues just 33???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-17-2000 07:42 AM
тАО10-17-2000 07:42 AM
Re: find and delete files at the same time ?
In xargs, those limits simply control the size of the argument list that can be passed to each iteration of the command specified.