Solved

Darkest Log

Posted on 2013-11-13
3
233 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now