We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

solrais equivalent of ls -lSr

Peewee
Peewee asked
on
Medium Priority
313 Views
Last Modified: 2013-12-27
what is the solaris equivalent of ls -lSr

basically i want to:
list files in the current directory by size
list the 10 biggest files in the current directory and in all sub directories.

thx Peewee
Comment
Watch Question

ls -Rl |sort -rk5|head

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
hi sheetbird,
thanks for your answer it does what i'm after.. how do i get the path name of the file to display aswell as the file name..

getting the path with ls is not possible.  I would suggest that you use a perl script.  Here's a quick hack of another script I wrote that will get the file name and the size

#!/usr/bin/perl
use Cwd;
use File::Find;
sub process_file {
($size) = (stat($_))[7];
        my $path = cwd;
        print "$size $path\/$_ \n";
}
if (!$ARGV[0]){
        die "I need a Directoy as input \n";
}
find(\&process_file, @ARGV);


Save it as getfilesize.pl and then you can pipe it to sort as done above

./getfilesize.pl <targetdir> | sort -nr|head

The whole thing can be done in perl but I didn't want to spend the time on it if perl is something you don't want to do.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.