LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-26-2006, 11:05 PM   #1
fjkum
Member
 
Registered: Feb 2006
Posts: 38

Rep: Reputation: 15
How to issue "ls" command start with the largest file size in a folder?


Hi,

How do I use the command "ls" to display the largest file size in a folder?
 
Old 07-26-2006, 11:16 PM   #2
AmphetaminePhreak
Member
 
Registered: Jul 2006
Location: kinda transient right now. Utah is Home, staying in Ohio
Distribution: Mandrake 9.1/Windows XP
Posts: 46

Rep: Reputation: 15
the most i could come up with is ls -s which gives you the size of all the files. i got this in the man pages

Code:
[matt@cpe-69-133-112-109 sounds]$ ls -s
total 80
48 turnmeon.wav    32 turnmeon.zip

man ls

Last edited by AmphetaminePhreak; 07-26-2006 at 11:19 PM.
 
Old 07-26-2006, 11:21 PM   #3
AAnarchYY
Member
 
Registered: Sep 2004
Location: Carlisle, MA
Distribution: Debian 8
Posts: 419

Rep: Reputation: 30
sort by size largest first
Code:
ls -S
 
Old 07-26-2006, 11:40 PM   #4
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 47
I would be inclined to use ls -lrS, which gives a long listing, sorted by size, with the largest last in the list (and therefore not scrolled off the screen).
 
Old 07-27-2006, 12:58 AM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 124Reputation: 124
ls -sSr and ls -sS are both also useful.
 
Old 07-27-2006, 04:28 AM   #6
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
hello fjkum. i guess you can also use du for that.

smallest first (recursive)
Code:
du * | sort -n
largest first (recursive)
Code:
du * | sort -nr
smallest first (not recursive)
Code:
du * -s | sort -n
largest first (not recursive)
Code:
du * -s | sort -nr
you can remove the numbers by adding '| cut -f 2'
Code:
du * -s | sort -nr | cut -f 2
by default the sizes are printed in kilobytes. add '-b' to du to print sizes in bytes.
Code:
du * -s -b | sort -nr
regards

Last edited by konsolebox; 07-27-2006 at 04:29 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"File size limit exceeded" during copy h3xis Linux - Networking 2 06-17-2006 02:24 PM
rename file with "mv" not working for folder? Niceman2005 Linux - Newbie 2 03-13-2005 10:34 PM
The command "df -h" no show me the size of partition true! sandrobr Linux - Enterprise 7 01-03-2005 04:31 AM
Cannot "Copy To" .jpg file to wallpaper folder LeanPudLou SUSE / openSUSE 5 11-08-2004 09:24 AM
My system freezes after I issue the "modprobe ndiswrapper" command. markjc Linux - Wireless Networking 1 08-24-2004 10:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration