[nSLUG] Any Perl Experience around?

Mike Spencer mspencer at tallships.ca
Thu Jun 22 01:05:19 ADT 2017


> ls -F --color | perl -lne 's/(.{24}).*/$1... /s ; print' | column -x
>
> [and other variants...]

Use ls -F, pipe to perl, parse the classification chars in perl and
add colour codes yourself in the perl print statement.  (Note that ls
doesn't colorize the classification chars which you can elide or not
as you like.)

See man 4 console_codes, page down to ECMA-48 for the codes.  Run ls
--color in an Emacs shell buffer (dumb terminal) to see which ones ls
normally uses and how multiple codes are concatenated with ';'.
(E.g. directory names are coded for both blue and bold.)

Easier than trying to write a regexp to manipulate the raw ls --color
output.


FWIW,
- Mike

-- 
Michael Spencer                  Nova Scotia, Canada       .~. 
                                                           /V\ 
mspencer at tallships.ca                                     /( )\
http://home.tallships.ca/mspencer/                        ^^-^^


More information about the nSLUG mailing list