regexp in the shell
Morris, Alex
alex.morris@jnli.com
Thu, 19 Apr 2001 12:53:50 -0400
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C0C8F1.4AEE3E98
Content-Type: text/plain;
charset="iso-8859-1"
I'm using the ksh shell and have a problem. I have a variable in one of my
scripts, and I need to extract a few characters from the variable and store
it in another variable (preferably without using a temp file).
The basic format of the variable is:
IMPLEMNTATION ----------------------- xxxxxxxx!yyyyy 1 record(s) selected.
I'm trying to extract that "xxxxxxxx" part. The number of dashes, "-", is
not static. The number of "x"'s is not static. And the number of "y"'s is
not static. I figure that I can search through the variable and pull out
everything between "----- " and "!", but I don't know how to search through
the variable...
Any idea how to do this, or what function to investigate? I was looking at
grep because it does regexp (which would make this easy) but it returns
lines that match a pattern, it cannot extract text from a line.
Any ideas?
Thanks,
Alex Morris
------_=_NextPart_001_01C0C8F1.4AEE3E98
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2650.12">
<TITLE>regexp in the shell</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=3D2 FACE=3D"Arial">I'm using the ksh shell and have a =
problem. I have a variable in one of my scripts, and I need to =
extract a few characters from the variable and store it in another =
variable (preferably without using a temp file).</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">The basic format of the variable =
is:</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">IMPLEMNTATION =
----------------------- xxxxxxxx!yyyyy 1 record(s) selected.</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">I'm trying to extract that =
"xxxxxxxx" part. The number of dashes, "-", =
is not static. The number of "x"'s is not static. =
And the number of "y"'s is not static. I figure that I =
can search through the variable and pull out everything between =
"----- " and "!", but I don't know how to search =
through the variable...</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Any idea how to do this, or what =
function to investigate? I was looking at grep because it does =
regexp (which would make this easy) but it returns lines that match a =
pattern, it cannot extract text from a line.</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Any ideas?</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Thanks,</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Alex Morris</FONT>
</P>
</BODY>
</HTML>
------_=_NextPart_001_01C0C8F1.4AEE3E98--