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

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -