- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Delete directory and files
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
10-20-2009 12:29 PM
10-20-2009 12:29 PM
I need to delete a specific directory on a number of servers.
The directories are under /home.
/home/abc_123
/home/abc_123.09122009
The thing is I need to delete only the directory with the date in it i.e. /home/abc_123.09122009 and not the /home/abc_123.
Can someone please advise on how to do it.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2009 12:36 PM
10-20-2009 12:36 PM
Re: Delete directory and files
# rm -rf /home/abc_123.09122009
...which will remove (recursively) the directory and all its contents.
Assuming that you have 'ssh' (or if you don't, use 'remsh' and do something like:
while read HOST X
do
ssh ${HOST} -n rm -rf /home/abc_123.09122009
done < file_of_hosts
...where the 'file_of_hosts" has the names or IP addresses of the servers to which you want to connect.
Substitute 'remsh ${HOST) -n ...' if necessary.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2009 12:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2009 12:54 PM
10-20-2009 12:54 PM
Re: Delete directory and files
rm -r /home/abc_123.[0-9]*
the -f option will only be needed if the files are in used, looking ad your request is looks like that you do not want to remove files that are in used... so never use -f (unless you realy need it and you know what you are doing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2009 12:59 PM
10-20-2009 12:59 PM
Re: Delete directory and files
# rm -r /home/abc_123.????200?
Buena suerte !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2009 01:16 PM
10-20-2009 01:16 PM
Re: Delete directory and files
You'll want the wildcard expression to be transferred to the remote host as-is, and then the remote host should expand the wildcards before actually executing the command.
Here's the suggestion of James, modified to delete directories with any date, not just .09122009.
while read HOST X
do
ssh ${HOST} -n rm -rf '/home/abc_123.????????'
done < file_of_hosts
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2009 06:40 PM
10-20-2009 06:40 PM
Re: Delete directory and files
#rm -Rf
is the command
If you satisfied with the answer and your problem got solved then please make a habit to assign points,
Those people who give there valuable time for your problem they should expect some apparition from you in terms of points.
To know how to assign points please go through the below link
http://forums13.itrc.hp.com/service/forums/helptips.do?admit=109447627+1256027208667+28353475#33
Thanks