»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 12-01-2003, 08:23 AM   #1 (permalink)
Registered User
 
Join Date: Dec 2003
Location: Ireland
Posts: 3
BrianKennedy is on a distinguished road
Food How do I list empty directories in Linux

Hi,

I'm a Linux newbee and I need help with a command.

- How do I list empty directories within a Linux environment??

All help accepted!

Thanks & Regards

BrianKennedy is offline   Reply With Quote
Old 12-01-2003, 08:34 AM   #2 (permalink)
Registered User
 
CMonster's Avatar
 
Join Date: Oct 2001
Location: Sunny, smogy Southern California
Posts: 5,350
CMonster is on a distinguished road
See below (notice that there is an empty directory):

Code:
Hello george, today is Mon Dec 01> pwd
/home/george
Hello george, today is Mon Dec 01> cd Desktop
Hello george, today is Mon Dec 01> pwd
/home/george/Desktop
Hello george, today is Mon Dec 01> ls -a
.                Floppy.desktop        New Terra                
..               GFTP                  Opera                    
.directory       Getting Grip to work  Oregon_Nikon             data1.desktop
.xvpics          Getty                 Oregon_trip              eBooks
100hp315         GraceWedding          Photos                   girl-cops
Birthday-2001    Green                 Printer.desktop          led_zeppelin
CD-R.desktop     HeartofGold.mp3       Raptor                  
CD-ROM.desktop   June Lake Trip        Star Office              multimedia
Camping-08-02    Konqueror             This-Directory-is-Empty  mybook2old
Cement Work      Mozilla.desktop       Tuxracer                 roundup
Compupic         My_Book_Desktop       WWW                      sound-wave
DVD-ROM.desktop  NH                    Wedding_Audry            visitors
Hello george, today is Mon Dec 01>

Last edited by CMonster; 12-01-2003 at 08:39 AM.
CMonster is offline   Reply With Quote
Old 12-01-2003, 08:44 AM   #3 (permalink)
Registered User
 
Join Date: Dec 2003
Location: Ireland
Posts: 3
BrianKennedy is on a distinguished road
CMonster,

Thanks 4 your reply. Maybe I was a bit vauge when posting the thread. What I need is a command that will only list empty directories. E.G I know ls -R lists all directories with files. What I require is listing only the empty directories.

thanks
BrianKennedy is offline   Reply With Quote
Old 12-01-2003, 03:45 PM   #4 (permalink)
Registered User
 
CMonster's Avatar
 
Join Date: Oct 2001
Location: Sunny, smogy Southern California
Posts: 5,350
CMonster is on a distinguished road
You could try the following, but it may give more output than you desire:

$ du -S . | sort -n (don't forget the "." dot)

It should list your empty directories first.
CMonster is offline   Reply With Quote
Old 12-09-2003, 02:47 AM   #5 (permalink)
Registered User
 
Join Date: Dec 2003
Location: Silicon Valley
Posts: 2
ThePythonicCow is on a distinguished road
list of empty directories

You can list all empty directories with:

find / -type d -empty
__________________
-- Mooo !!!
ThePythonicCow is offline   Reply With Quote
Old 12-09-2003, 03:09 AM   #6 (permalink)
Registered User
 
lynchmob's Avatar
 
Join Date: Oct 2001
Location: Mid-Atlantic
Posts: 1,361
lynchmob is on a distinguished road
Re: list of empty directories

Quote:
Originally posted by ThePythonicCow
You can list all empty directories with:

find / -type d -empty
That seems to work pretty well.
Thanks
lynch
__________________
Seldom right,but never in doubt...
lynchmob is offline   Reply With Quote
Old 12-09-2003, 07:04 AM   #7 (permalink)
Registered User
 
Join Date: Dec 2003
Location: Ireland
Posts: 3
BrianKennedy is on a distinguished road
Misc

lynch,

This worked perfectly. Thanks a lot!
BrianKennedy is offline   Reply With Quote
Old 12-09-2003, 02:51 PM   #8 (permalink)
Registered User
 
CMonster's Avatar
 
Join Date: Oct 2001
Location: Sunny, smogy Southern California
Posts: 5,350
CMonster is on a distinguished road
I knew someone had to know...
CMonster is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 10:04 AM.