Skip to content

Instantly share code, notes, and snippets.

@heypano
Created August 15, 2013 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heypano/6240849 to your computer and use it in GitHub Desktop.
Save heypano/6240849 to your computer and use it in GitHub Desktop.
sorts ls results by permission - Useful for finding similar files or folders
#! /usr/bin/perl
my @entries = reverse sort by_first_column `ls -la @ARGV`;
print @entries;
sub by_first_column{
(my $a1 = $a) =~ s/^[\s]*([\S]+).+$/$1/;
(my $b1 = $b) =~ s/^[\s]*([\S]+).+$/$1/;
return $a1 cmp $b1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment