- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Remove empty directory
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
тАО03-01-2009 10:45 PM
тАО03-01-2009 10:45 PM
Remove empty directory
Can anyone tell me how to remove empty directories which are created before 30 days .
ie i have to remove empty directores from /usr1 filesystem.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2009 11:07 PM
тАО03-01-2009 11:07 PM
Re: Remove empty directory
Please execute the following command:
enter the diectory and execute: ls -al
If the directory is empty then execute:
rm -rf /user1
Rgds-kranti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-01-2009 11:21 PM
тАО03-01-2009 11:21 PM
Re: Remove empty directory
i want a command which will find out and delete those dirs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 12:09 AM
тАО03-02-2009 12:09 AM
Re: Remove empty directory
for DIR in $(find /usr1 -type d - mtime +30)
do
cd $DIR
EMPTY=`ls`
if [[ $EMPTY = "" ]]
then
rm $DIR
fi
done
You will need to tweak this before running on a live system. I am not in front of a unix box to get the commands exactly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 12:21 AM
тАО03-02-2009 12:21 AM
Re: Remove empty directory
Mark gave you the find command.
Do delete empty dirs check the command 'rmdir' - this command deletes empty directories (see 'man rmdir').
make a test before ...
HTH
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 01:01 AM
тАО03-02-2009 01:01 AM
Re: Remove empty directory
find /usr1 -type d -mtime +30 -depth -exec rmdir {} \; 2>/dev/null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 03:53 AM
тАО03-02-2009 03:53 AM
Re: Remove empty directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 09:28 AM
тАО03-02-2009 09:28 AM
Re: Remove empty directory
You might want to just redirect rmdir errors and not find errors. And use + for performance:
find /usr1 -type d -mtime +30 -depth -exec rmdir {} 2> /dev/null +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-02-2009 03:12 PM
тАО03-02-2009 03:12 PM
Re: Remove empty directory
Oops, the only way to get this to work is to create a script to do the rmdir and then redirect stderr:
find /usr1 -type d -mtime +30 -depth -exec rmdir_script {} +
rmdir_script:
#!/usr/bin/ksh
rmdir "$@" 2> /dev/null