Thursday, April 21, 2016

old school unix text processing

Sometimes it's nice to know about old school unix command line tools - though I'd welcome other solutions to this problem:

At work, we wanted to move some "human readable error messages" processing to the front end. One aspect of this was to get a list of the error codes a certain service could produce (since we didn't necessarily want to come up with human readable version of VERY error the whole backend system could produce.)

The error constants where all of the form ErrorMessages.SOME_VALUE. so my first step was top copy and paste the contents of the file (a little easier than locating it on the file system in terminal) into
grep ErrorMessage > tmp.txt
Then I copy and pasted that (again, pipes is the cooler way, but whatever) into my editor, hand tweaked some of the content to make it consistent (push all the entries to the left side and getting rid of any other code that snuck in on those lines) and then copy and pasted THAT into
sort | uniq > tmp2.txt
(Uniq says show me only one copy of a line for a block of repeated lines, but if you sort it first, it will make sure you only see one per actually unique line.)

And now I have a list of potential error codes to ask my product manager about!

No comments:

Post a Comment