Find string like XXXX - XXXX - XXXX in a file using bash -


is there way find string xxxx-xxxx-xxxx (where xs numbers , letters) in file using bash?

for example: have aaaaaaaa-aaa-aaa-xxxx-xxxx-xxxx string in text file , want extract xxxx-xxxx-xxxx (there 4 letters/numbers group rapresented xs).

if not possible using bash, there other way this?

thanks.

grep -eo '\<[[:alnum:]]{4}-[[:alnum:]]{4}-[[:alnum:]]{4}\>' file 
  • -o outputs matched text
  • use word boundary markers \< , \> prevent false matches "12345-1234-12345"

Comments

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -