The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Removing empty folders using 'find' deTTo UNIX for Dummies Questions & Answers 5 04-21-2008 10:24 PM
Removing empty folders using the "find" command biot UNIX for Dummies Questions & Answers 3 03-25-2008 10:43 PM
zip nesting empty folders groundlevel UNIX for Dummies Questions & Answers 0 09-29-2006 12:08 AM
How to find files not empty? videsh77 UNIX for Dummies Questions & Answers 2 02-26-2006 09:15 AM
/dev/rmt empty ppass SUN Solaris 1 08-04-2005 12:34 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-16-2008
lasse lasse is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 4
how to find empty folders without using -empty

hi all:
my solaris FIND does not support
Code:
find myFolder -type d -empty
how can i find the empty folders?
thanks!
  #2 (permalink)  
Old 01-16-2008
abanna abanna is offline
Registered User
  
 

Join Date: Jun 2006
Location: cairo
Posts: 4
du -ks * | sort -n

Result like that:

Size Dir Name
0 DEACT_TOTO

--------------------

Or

ls -ltr | grep "^d" | awk '{print $9}' | xargs -i du -ks {} | sort -n
  #3 (permalink)  
Old 01-16-2008
lasse lasse is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 4
Code:
mkdir aa1 aa2
du -ks * |sort -n
the result is
1 aa1
1 aa2

and i TOUCH a new file in aa1, run again, the result still:
1 aa1
1 aa2

-size 0 can not work for empty folder
  #4 (permalink)  
Old 01-16-2008
lasse lasse is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 4
Hi all, does this code do the job?
Code:
#!/bin/ksh
find myfolder -type d|while read name
do
if (( $(ls -al $name|wc -l) == 3 ))
then
echo $name
fi
done
  #5 (permalink)  
Old 01-16-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,539
Quote:
Originally Posted by lasse View Post
Hi all, does this code do the job?
Code:
#!/bin/ksh
find myfolder -type d|while read name
do
if (( $(ls -al $name|wc -l) == 3 ))
then
echo $name
fi
done
try it out on the command line.
  #6 (permalink)  
Old 01-16-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,539
Code:
# ls -l * | awk '/total 0/{print last}{last=$0}'
  #7 (permalink)  
Old 01-17-2008
lasse lasse is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 4
Quote:
Originally Posted by ghostdog74 View Post
try it out on the command line.
HI,
i wrote it and have tested but want someone to confirm.
thx
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0