Im looking to search through a file containing a list of license plates.

If the license plates are formatted as ABAA BAB, where A is a number and B is the letter of an alphabet, is it possible to search and get a list of all plates similar in formatting?


  • 2
    Could you please add some more specific examples? – phk Mar 13 '17 at 21:29
  • Also, for your example you could simply do grep '^[0-9][A-Z][0-9][0-9] [A-Z][0-9][0-9]$' /path/to/file but I guess that's not what you are looking for? – phk Mar 13 '17 at 21:31

If you want to just extract all the license plates that match that pattern from a file:

grep -Eo '[0-9][A-Z][0-9]{2} [A-Z][0-9]{2}' /path/to/file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.