[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

Darkest Log

I have a large number of log files, that consist of only a hex based 'html' rgb color code. So a log file might be called blah.log, and inside of it, it will have only one 'word'. The 'word' is a html color value between 000000 and FFFFFF. That value is basically 3 different values between 00 and FF, put together for the RGB value of the color.

What I would like to do is to take all .log files, open them to find the value, and then order the log file names in a list from lightest to darkest. From 000000 to FFFFFF.

So, if the log files were called 1.log, 2.log, and 3.log and they were each darker than one before it, the result would be:

1.log
2.log
3.log

Does that make sense?
0
stakor
Asked:
stakor
  • 2
1 Solution
 
ozoCommented:
Is this what you mean?
perl -ne '$d{pack"n",unpack"%C*",pack"H6",$_}=$ARGV;END{rename $d{$_},++$n.".log" or warn "$d{$_} $n.log $!" for sort keys %d}' *.log
0
 
ozoCommented:
Maybe it's more likely that you mean this:
perl -lne '$d{pack"n",unpack"%C*",pack"H6",$_}=$ARGV;END{print $d{$_} for sort keys %d}' *.log
0
 
stakorAuthor Commented:
Thank you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now