[nSLUG] Any Perl Experience around?

Joel Maxuel j.maxuel at gmail.com
Sat Jun 24 11:15:29 ADT 2017


By the way, this is the exact point in time `column` was updated so a
colour input would not be a problem. First release with it is 9.0.7 as part
of the BSDMainUtils package - Debian Jessie (for example) uses version
9.0.6:

https://anonscm.debian.org/cgit/bsdmainutils/bsdmainutils.git/commit/?id=c110f76fd300c58274266e171f3d10776f477bce


--
Cheers,
Joel Maxuel

"One should strive to achieve, not sit in bitter regret."
 - Ronan Harris / Mark Jackson

On Thu, Jun 22, 2017 at 5:45 PM, Joel Maxuel <j.maxuel at gmail.com> wrote:

> Interestingly enough (on my system), comparing the last two examples to
> one previous to that, it's the last two examples that have indenting issues
> whereas the one previous does not.  The `column` command may have been
> fixed in Debian Stretch for that matter (the version I am running) to
> render colourization.  For chuckles, I also tried with the GNU Autogen's
> Columns command, and decided to not mess with a good thing.
>
> This is relevant for others:
> https://unix.stackexchange.com/questions/251751/issue-
> with-column-command-and-color-escape-codes
>
> The final side effect is that a few colourized files are truncated 7
> characters shorter than their peers (first half of second line)...
>
> bitware-lite-3.22-01...    bitware-lite-3.22-01...    blankdisk.img
> boot.img
> budget - 2014...    BudgetDBFront...    budget - last 12mo.p...    budget
> - last year.p...
> Build/            camera2.log        camera.log        camshite
>
> But I am not concerned about that.
>
> Hatem, do you have a github account?  If you like I can attribute you in
> this work in the commit message for my cli tools project (I usually use the
> format of "First and Last Name (GithubAccountName)").  Thanks once again.
>
>
> --
> Cheers,
> Joel Maxuel
>
> "One should strive to achieve, not sit in bitter regret."
>  - Ronan Harris / Mark Jackson
>
> On Thu, Jun 22, 2017 at 1:27 PM, Hatem Nassrat <hnassrat at gmail.com> wrote:
>
>>
>>
>> On Thu, Jun 22, 2017 at 12:46 PM, Hatem Nassrat <hnassrat at gmail.com>
>> wrote:
>>>
>>> Your problem is most likely with the column command. Also this is a long
>>> explanation to say my regex is solid :P
>>>
>>
>> Here is a version of the command that works, it essentially adds 10
>> spaces on lines that have colors, (counted by looking at the file in vim,
>> without the initial escape character, each colored line has 10 characters
>> of color stuff). This means that your columnar output is now 10 chars
>> longer, so you need to consider that in your char count inside the curly
>> brackets inside. Essentially none colored file names are penalized ... what
>> can be done there is a slightly more complex regex where the non colored
>> lines are allowed an extra 10 characters from their colored counterparts.
>> Both below.
>>
>> /bin/ls -Fc --color | perl -lne 's/((?:\e\[\d+(?:;\d+)?m)*)([^
>> \e]{24})[^\e]*(.*)/$1$2...$3/s; print' | column -x | perl -lne
>> 's/(\e\[0m[^\t]*)(\t)/$1          $2/sg; print'
>>
>> OR
>>
>> # note I made the length 5 and 15 for testing, changing it to 24 and 34
>> should match the original github code size for the 2 col version
>>
>> /bin/ls -Fc --color | perl -lne 's/(?:((?:\e\[\d+(?:;\d+)?m)+)
>> ([^\e]{5})[^\e]*(.*))|(?:(.{15}).*)/$1$2$4...$3/s; print' | column -x |
>> perl -lne 's/(\e\[0m[^\t]*)(\t)/$1          $2/sg; print'
>>
>> --
>> Hatem
>>
>>
>> _______________________________________________
>> nSLUG mailing list
>> nSLUG at nslug.ns.ca
>> http://nslug.ns.ca/mailman/listinfo/nslug
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nslug.ns.ca/pipermail/nslug/attachments/20170624/c95fd5ab/attachment.html>


More information about the nSLUG mailing list