![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script to remove all empty files within the directory structure? | cat123 | Shell Programming and Scripting | 5 | 06-05-2008 10:01 AM |
| Setting the right directory as non-empty | olimiles | Shell Programming and Scripting | 0 | 08-31-2006 11:31 AM |
| Remove non empty dirctory | adol3 | SUN Solaris | 5 | 12-14-2005 02:23 AM |
| rmdir a non-empty directory. | yls177 | UNIX for Dummies Questions & Answers | 2 | 12-11-2002 07:44 AM |
| smitty, remove user, remove directory as well.. | yls177 | UNIX for Dummies Questions & Answers | 2 | 11-11-2002 02:43 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
remove empty directory
Hi, I need to delete an empty directory in a temp directory except "dir5" (keep everything that is not empty). Plese advise. Here is an example of my directory. /dir/temp/ dir1 - delete if this is empty dir2 - delete if this is empty dir3 - delete if this is empty dir4 - delete if this is empty dir5 - I don't want to delete this folder at all. Here is what I got so far Code:
if [ "$(ls -1 /dir/temp |grep -v "dir5")" ]
then
echo "directory is Not Empty"
rmdir $(ls -1 /dir/temp |grep -v "dir5")
else
echo "this directory is Empty"
rmdir $(ls -1 /dir/temp |grep -v "dir5")
fi
Last edited by Yogesh Sawant; 04-09-2009 at 08:22 AM.. Reason: added code tags |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|