As a detailed here, you want to create a positive lookbehind condition, for example:
grep -P '(?<=name=)[ A-Za-z0-9]*' filename
-P makes grep use the Perl dialect, otherwise you will probably need to avoid parentheses. You can also mark, as indicated elsewhere, add the -o option to print only what matches. The part in parentheses indicates that you want alphanumeric characters and spaces.
The advantage of using the positive lookbehind clause is that the text name = is not part of the match. If grep selects consistent text, it will only select the alphanumeric (and spatial) part. The -o option also does not display the "name =" part. And if you switch to another program, for example sed, which can capture text and do something with it, you will not capture the "name =" part, although you can also do this using the parent mines capture.
markets Aug 08 '09 at 2:52 2009-08-08 02:52
source share