Linux: command to recursively list all files by size?

Hi All,

I’ve just misplaced one of the most useful linux command line strings: a single string that, for the current directory, displays a list of all files (recursively, i.e. including all files in all sub directories) by file size, starting with the biggest file first. Next to each file name should be it’s file size.

  • The list should not show directories - only files
  • The list should show the path to each of the files

I’m no linux command line guru. The string that I had just worked, and so whenever I needed it I just cut and paste it from a knowledge base thing where I had it stored - but somehow it’s been accidentally deleted.

Help! :slight_smile:

Found it! :slight_smile:

find . -type f -printf '%s %p
’ | sort -rn | less | more

Err… why the


that just pipes it from one pager into another.

Yes, it does, and agreed - not strictly necessary. It’s simply so that if someone is completely unfamiliar with command line linux then they might otherwise not know how to stop the (normally long) list from scrolling fast up the screen. So they can cut and paste the string ‘as is’, and press the space bar (or any key I think) to scroll one screenfull at a time. :slight_smile:

the command would work exactly the same without the “|more” as the “|less” already views the output in a pager program which allows the space bar to move to the next full page, but also allows the added functionality of pressing the “up or down arrow” button to scroll by line.

No, less will function like cat here, if less’s stdout isn’t on a terminal it doesn’t do anything other put stdin to stdout, so the ‘active’ pager would be more in a command like foobar | less | more.

spaceman throw this in you ~/ directory ( user account /home/somename ) and name it .Xdefaults it sets up some nice colors xft fonts and makes it so | less isn’t needed as much ( you can scroll up and down )

Xterm colors

XTerm*Background: #ffffff
XTerm*Foreground: #636363
XTerm*color0: #000000
XTerm*color1: #963c59
XTerm*color2: #aace92
XTerm*color3: #968a38
XTerm*color4: #414171
XTerm*color5: #963c59
XTerm*color6: #418179
XTerm*color7: #bebebe
XTerm*color8: #666666
XTerm*color9: #cf6171
XTerm*color10: #afdb6b
XTerm*color11: #fff796
XTerm*color12: #4186be
XTerm*color13: #cf9ebe
XTerm*color14: #71bebe
XTerm*color15: #ffffff
XTerm*CursorColor: #dcdcdc

Xterm fonts

XTerm*FaceName: default
XTerm*FaceSize: 10

Xterm options

XTerm*AutoWrap: on
XTerm*BorderWidth: 10
XTerm*CacheDoublesize: 100
XTerm*CharClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48,35:48,58:48
XTerm*CutNewLine: off
XTerm*CutToBeginningOfLine: off
XTerm*JumpScroll: on
XTerm*Locale: on
XTerm*LoginShell: on
XTerm*MultiScroll: on
XTerm*ScrollKey: true
XTerm*ScrollTtyOutput: off
XTerm*ptyHandshake: off
XTerm*SaveLines: 2048

That will only work for xterm (most people use konsole, gnome-terminal, eterm or aterm now, and some people still use tty’s and vc’s) and will only work with a program (i.e. shell) that supports it.