On 1/10/06, Zhao Peng <[EMAIL PROTECTED]> wrote:
> how could I extract the string which
> contains "univ" and create an output file called def.txt, which only has
> 3 following lines:

Here's one way, as a Perl one-liner:

perl -ne 'split ","; $_ = $_[2]; s/(^")|("$)//g; print if m/univ/;' <
abc.txt > def.txt

That trims out the quotes, as it appears you want.  The search for
"univ" is case-sensitive.

Broken down into a script with comments:

#!/usr/bin/perl -n
split ",";         # split input fields into @_ (split at commas)
$_ = $_[2];        # grab the third field, put into default workspace ($_)
s/(^")|("$)//g;    # delete double-quote (") at start and/or end
print if m/univ/;  # print if contains "univ"

  HTH,

-- Ben
_______________________________________________
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss

Reply via email to