Solved

Darkest Log

Posted on 2013-11-13
3
254 Views
Last Modified: 2013-11-13
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
Comment
Question by:stakor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 39644001
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
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39644129
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
 

Author Closing Comment

by:stakor
ID: 39646269
Thank you.
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question