This "down-to-earth" squirrel is building a nest containing nuggets of Perl Techniques, tips, and tricks for useful application development, data conversion scripts and one-liners. UNIX/Linux shell scripting topics will also be added.
Sunday, November 22, 2009
AWK - Sort lines from shortest to longest
Display filenames in a directory with the shortest filenames first and longest length last:
ls -1 | awk '{printf "%d\t%s\n", length($0), $0}' | sort +0n -1 | sed 's/^[0-9][0-9]* //'