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 - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -