How do I use grep to extract a specific field value from lines
Posted
by Stormshadow
on Stack Overflow
See other posts from Stack Overflow
or by Stormshadow
Published on 2010-06-18T13:48:24Z
Indexed on
2010/06/18
13:53 UTC
Read the original article
Hit count: 202
grep
I have lines in a file which look like the following
....... DisplayName="john" ..........
where ....
represents variable number of other fields.
Using the following grep command, I am able to extract all the lines which have a valid 'DisplayName' field
grep DisplayName="[0-9A-Za-z[:space:]]*" e:\test
However, I wish to extract just the name (ie "john") from each line instead of the whole line which is returned by grep. I tried pipelining the output to the cut command but it does not accept string delimiters.
© Stack Overflow or respective owner