Skip to content
Advertisement

U-Boot version extraction for comparision

I am trying to extract U-Boot version from its binary for comparison,
consider that exact string what I want to search is as follow,

JavaScript

so I wrote command with regex as follows,

JavaScript

However I don’t see any output for that above command,

I could make below command work which extracts version only by comparing versions and not looking for date in the string

JavaScript

Could someone correct/suggest what am I doing wrong in first command?
Is there a better way of doing the same ?

Advertisement

Answer

Your regex in 1st command is broken, you need to escape few chars like the dot for a proper match, also for matching the month i.e Mar you need [A-Za-z]{3} but you have specified only [a-z]{3}

Also you can use the -o switch to just print out the matched part. From the man page of grep:

-o, –only-matching Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.

To extract just the version use anyone of these:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement