Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


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 !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-15-2012
Registered User
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
List biggest files (Not Directories)

Hello, can you please help me writing a command that would output the biggest files on my system from biggest to smallest? I want this to print only the files, not the directories.

I have tried

Code:
du -a ~ | sort -nr | head -10

However, this also prints out all the directories - which I do not want.


Thank you so much, you would do me a big favor!
Sponsored Links
    #2  
Old 03-15-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,400
Thanks: 492
Thanked 2,537 Times in 2,420 Posts

Code:
du -a |
while read SIZE LINE
do
        [ -d "$LINE" ] || echo $SIZE "$LINE"
done | sort -rn | head

Sponsored Links
    #3  
Old 03-15-2012
Registered User
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Corona688 View Post
Code:
du -a |
while read SIZE LINE
do
        [ -d "$LINE" ] || echo $SIZE "$LINE"
done | sort -rn | head

Thank you for the reply. However, when I run it on "tcsh" shell, i get the following error: Invalid null command.

Any ideas?
    #4  
Old 03-15-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,400
Thanks: 492
Thanked 2,537 Times in 2,420 Posts
Try it in a POSIX shell, your system certainly has one. Perhaps /bin/sh or /usr/bin/sh. tcsh is missing several of the constructs I'm using here, among many other problems.

CSH programming considered harmful
Sponsored Links
    #5  
Old 03-15-2012
Registered User
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Corona688 View Post
Try it in a POSIX shell.
I cant, I only have access to a tcsh/csh
Sponsored Links
    #6  
Old 03-15-2012
Mead Rotor
 
Join Date: Aug 2005
Location: Saskatchewan
Posts: 16,400
Thanks: 492
Thanked 2,537 Times in 2,420 Posts
Any UNIX system has a Bourne shell somewhere, it's a non-optional feature, and not something they can easily deny people access to. What system are you using?
Sponsored Links
    #7  
Old 03-15-2012
Registered User
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Corona688 View Post
Any UNIX system has a Bourne shell somewhere, it's a non-optional feature. What system are you using?

I am not even sure, I am really new to unix.

Can you provide any other alternatives?

ls?
find?
Sponsored Links
Closed Thread

Tags
du, file, size, unix, unix file du size

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
list directories with more than X files vanessafan99 UNIX for Dummies Questions & Answers 5 11-02-2011 05:50 PM
List directories and sub directories recursively excluding files pointers UNIX for Dummies Questions & Answers 3 02-23-2011 08:39 PM
How to get a list of files in a dir w/o sub-directories? aoussenko Shell Programming and Scripting 4 07-23-2010 09:19 AM
List directories and files psalas UNIX for Dummies Questions & Answers 2 07-07-2008 12:28 PM
List specific files from directories Filippo Shell Programming and Scripting 4 02-17-2005 02:56 AM



All times are GMT -4. The time now is 06:53 AM.