I have a large text file that is all one line.  In the text are several sections that looks like foo=12345 and I need to extract them all as separate lines, ignoring the rest of the file.For example:random junk foo=12345 more junk random junk foo=2345 junk foo=7654 junk random foo=5432 junkWhat I want to get out is:12345234576545432I know how to write the regex to extract the foo=([0-9]+), but I'm not sure how to apply that to the text and get the lines out in bash.
Extracting text from a text file in bash
bash;shell;grep;regular expression;string
$> echo random junk foo=12345 more junk random junk foo=2345 junk foo=7654 junk random foo=5432 junk | grep --only-matching --perl-regexp (?<=foo=)[0-9]+12345234576545432What we've done here is use lookbehind regex in (?<=foo=)[0-9]+.