Selecting patterns from the results of grep

Hi All,

I'm struggling with a problem that I'm wondering (and hoping!) that someone can help me with.

I have a number of .xml files which I'm using grep to search for the string 'include'. I need to extract the value of the include from the grep result.

For example, on any given file, I use 'grep -i include=' which returns:
<li include="NX">threadpool environment.....

In this example, I need to strip out the 'NX'. Ultimately, I need anything that is present between "" and follows 'include='.

These patterns can occur anywhere in the file. Unfortunately, my limited knowledge of sed and awk is proving insufficient to progress.

Thanks in Advance.

try this perl script:

#!/usr/bin/perl
# show_includes.pl
while (<>) {
    while (m/include=\"(.*?)\"/ig) {
        print $1, "\n";
    }
}

run this script as:

perl show_includes.pl filename.xml

A beautifully elegant solution that, more importantly, works :slight_smile:

Many thanks Yogesh.