Capturing text with Awk
am 02.10.2007 20:21:50 von mcbalagtas
I'm trying capture a string of text generated from one script. The
string will be used as input for another script.
I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
and the date.
Here is the output file from the 1st script:
Daily codes for Alpha
10/01/07 CTVGZLCS
10/02/07 5RQVGZQS
10/03/07 CP9GUMFB
Daily codes for Bravo
10/01/07 MG5G2TUV
10/02/07 NTYC5KIU
10/03/07 PI4OAXJ2
Daily codes for Charlie
10/01/07 ORCITFXF
10/02/07 XVST23FG
10/03/07 SWPHHNA2
I'm new to shell/awk scripting. I tried the following, but the output
is not correct.
I think I need to grab the 3 lines under each 'release' and then
filter it, but I couldn't figure that out.
Any help with the logic of what I need to do would be appreciated. I'm
using "Teach Yourself Shell Scripting in 24hrs" by Sriranga
Veeraraghavan as my reference (as well as the internet). If there are
better books, please recommend some.
I'm using this task as a chance to learn shell scripting.
Here is what I came up with. Eventually, release and reldate will be
input by the user.
=========================================
#!/usr/bin/sh
release=Charlie
reldate=$(date +%D)
dailycode > ratemp
awk '
($4=release) && ($1 = reldate) { print $2 ;}
'release="$release" reldate="$reldate"
ratemp
==========================================
Re: Capturing text with Awk
am 02.10.2007 21:55:03 von Ed Morton
mcbalagtas@yahoo.com wrote:
> I'm trying capture a string of text generated from one script. The
> string will be used as input for another script.
>
> I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
> and the date.
>
> Here is the output file from the 1st script:
>
> Daily codes for Alpha
> 10/01/07 CTVGZLCS
> 10/02/07 5RQVGZQS
> 10/03/07 CP9GUMFB
>
> Daily codes for Bravo
> 10/01/07 MG5G2TUV
> 10/02/07 NTYC5KIU
> 10/03/07 PI4OAXJ2
>
> Daily codes for Charlie
> 10/01/07 ORCITFXF
> 10/02/07 XVST23FG
> 10/03/07 SWPHHNA2
>
>
> I'm new to shell/awk scripting. I tried the following, but the output
> is not correct.
>
> I think I need to grab the 3 lines under each 'release' and then
> filter it, but I couldn't figure that out.
>
> Any help with the logic of what I need to do would be appreciated. I'm
> using "Teach Yourself Shell Scripting in 24hrs" by Sriranga
> Veeraraghavan as my reference (as well as the internet). If there are
> better books, please recommend some.
>
> I'm using this task as a chance to learn shell scripting.
>
> Here is what I came up with. Eventually, release and reldate will be
> input by the user.
> =========================================
>
> #!/usr/bin/sh
> release=Charlie
> reldate=$(date +%D)
> dailycode > ratemp
>
> awk '
> ($4=release) && ($1 = reldate) { print $2 ;}
> 'release="$release" reldate="$reldate"
> ratemp
> ==========================================
>
awk -v release="$release" -v reldate="$reldate" '
/^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
relfound && $1 == reldate { print $2 }' ratemp
Regards,
Ed.
Re: Capturing text with Awk
am 02.10.2007 22:22:42 von Glenn Jackman
At 2007-10-02 03:55PM, "Ed Morton" wrote:
> mcbalagtas@yahoo.com wrote:
> > I'm trying capture a string of text generated from one script. The
> > string will be used as input for another script.
> >
> > I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
> > and the date.
> >
> > Here is the output file from the 1st script:
> >
> > Daily codes for Alpha
> > 10/01/07 CTVGZLCS
> > 10/02/07 5RQVGZQS
> > 10/03/07 CP9GUMFB
> >
> > Daily codes for Bravo
> > 10/01/07 MG5G2TUV
> > 10/02/07 NTYC5KIU
> > 10/03/07 PI4OAXJ2
> >
> > Daily codes for Charlie
> > 10/01/07 ORCITFXF
> > 10/02/07 XVST23FG
> > 10/03/07 SWPHHNA2
> >
[...]
> > Here is what I came up with. Eventually, release and reldate will be
> > input by the user.
> > =========================================
> >
> > #!/usr/bin/sh
> > release=Charlie
> > reldate=$(date +%D)
> > dailycode > ratemp
> >
> > awk '
> > ($4=release) && ($1 = reldate) { print $2 ;}
> > 'release="$release" reldate="$reldate"
> > ratemp
> > ==========================================
> >
>
> awk -v release="$release" -v reldate="$reldate" '
> /^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
> relfound && $1 == reldate { print $2 }' ratemp
Another approach:
dailycode | awk -v release="$release" -v reldate="$reldate" '
/^Daily codes/ {state = $4; next}
! /^$/ {code[state "," $1] = $2}
END {print code[release "," reldate]}
'
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
Re: Capturing text with Awk
am 02.10.2007 22:50:41 von Ed Morton
Glenn Jackman wrote:
> At 2007-10-02 03:55PM, "Ed Morton" wrote:
>
>> mcbalagtas@yahoo.com wrote:
>>
>>>I'm trying capture a string of text generated from one script. The
>>>string will be used as input for another script.
>>>
>>>I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
>>>and the date.
>>>
>>>Here is the output file from the 1st script:
>>>
>>>Daily codes for Alpha
>>>10/01/07 CTVGZLCS
>>>10/02/07 5RQVGZQS
>>>10/03/07 CP9GUMFB
>>>
>>>Daily codes for Bravo
>>>10/01/07 MG5G2TUV
>>>10/02/07 NTYC5KIU
>>>10/03/07 PI4OAXJ2
>>>
>>>Daily codes for Charlie
>>>10/01/07 ORCITFXF
>>>10/02/07 XVST23FG
>>>10/03/07 SWPHHNA2
>>>
>
> [...]
>
>>>Here is what I came up with. Eventually, release and reldate will be
>>>input by the user.
>>>=========================================
>>>
>>>#!/usr/bin/sh
>>>release=Charlie
>>>reldate=$(date +%D)
>>>dailycode > ratemp
>>>
>>>awk '
>>> ($4=release) && ($1 = reldate) { print $2 ;}
>>> 'release="$release" reldate="$reldate"
>>>ratemp
>>>==========================================
>>>
>>
>>
>> awk -v release="$release" -v reldate="$reldate" '
>> /^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
>> relfound && $1 == reldate { print $2 }' ratemp
>
>
> Another approach:
>
> dailycode | awk -v release="$release" -v reldate="$reldate" '
> /^Daily codes/ {state = $4; next}
> ! /^$/ {code[state "," $1] = $2}
> END {print code[release "," reldate]}
> '
>
>
and another:
awk -v RS= -v release="$release" -v reldate="$reldate" '
$4 == release { for (i=5; i
the list is endless....
In your example, I'd have used code[state,$1] instead of
code[state","$1] since awk supports simulated 2D arrays. I wouldn't
really use that approach, though, as there's no benefit to it, it uses
more memory than necessary and it makes it harder to add an "exit" if
the OP wants to quit on the first hit.
Ed.
Re: Capturing text with Awk
am 02.10.2007 22:55:27 von mcbalagtas
On Oct 2, 12:55 pm, Ed Morton wrote:
> mcbalag...@yahoo.com wrote:
> > I'm trying capture a string of text generated from one script. The
> > string will be used as input for another script.
>
> > I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
> > and the date.
>
> > Here is the output file from the 1st script:
>
> > Daily codes for Alpha
> > 10/01/07 CTVGZLCS
> > 10/02/07 5RQVGZQS
> > 10/03/07 CP9GUMFB
>
> > Daily codes for Bravo
> > 10/01/07 MG5G2TUV
> > 10/02/07 NTYC5KIU
> > 10/03/07 PI4OAXJ2
>
> > Daily codes for Charlie
> > 10/01/07 ORCITFXF
> > 10/02/07 XVST23FG
> > 10/03/07 SWPHHNA2
>
> > I'm new to shell/awk scripting. I tried the following, but the output
> > is not correct.
>
> > I think I need to grab the 3 lines under each 'release' and then
> > filter it, but I couldn't figure that out.
>
> > Any help with the logic of what I need to do would be appreciated. I'm
> > using "Teach Yourself Shell Scripting in 24hrs" by Sriranga
> > Veeraraghavan as my reference (as well as the internet). If there are
> > better books, please recommend some.
>
> > I'm using this task as a chance to learn shell scripting.
>
> > Here is what I came up with. Eventually, release and reldate will be
> > input by the user.
> > =========================================
>
> > #!/usr/bin/sh
> > release=Charlie
> > reldate=$(date +%D)
> > dailycode > ratemp
>
> > awk '
> > ($4=release) && ($1 = reldate) { print $2 ;}
> > 'release="$release" reldate="$reldate"
> > ratemp
> > ==========================================
>
> awk -v release="$release" -v reldate="$reldate" '
> /^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
> relfound && $1 == reldate { print $2 }' ratemp
>
> Regards,
>
> Ed.
Thanks for the reply Ed.
I'm getting the following error msg:
../ra2.sh[11]: /^Daily /{relfound=($4==release ? 1 : 0)}^J
relfound && $1==r
eldate {print $2}: not found
Also, could you explain the syntax of this ($4==release ? 1 : 0)?
Specifically, the '?' and the '1:0'
Re: Capturing text with Awk
am 02.10.2007 23:17:53 von Ed Morton
mcbalagtas@yahoo.com wrote:
> On Oct 2, 12:55 pm, Ed Morton wrote:
>
>>mcbalag...@yahoo.com wrote:
>>
>>>I'm trying capture a string of text generated from one script. The
>>>string will be used as input for another script.
>>
>>>I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
>>>and the date.
>>
>>>Here is the output file from the 1st script:
>>
>>>Daily codes for Alpha
>>>10/01/07 CTVGZLCS
>>>10/02/07 5RQVGZQS
>>>10/03/07 CP9GUMFB
>>
>>>Daily codes for Bravo
>>>10/01/07 MG5G2TUV
>>>10/02/07 NTYC5KIU
>>>10/03/07 PI4OAXJ2
>>
>>>Daily codes for Charlie
>>>10/01/07 ORCITFXF
>>>10/02/07 XVST23FG
>>>10/03/07 SWPHHNA2
>>
>>>I'm new to shell/awk scripting. I tried the following, but the output
>>>is not correct.
>>
>>>I think I need to grab the 3 lines under each 'release' and then
>>>filter it, but I couldn't figure that out.
>>
>>>Any help with the logic of what I need to do would be appreciated. I'm
>>>using "Teach Yourself Shell Scripting in 24hrs" by Sriranga
>>>Veeraraghavan as my reference (as well as the internet). If there are
>>>better books, please recommend some.
>>
>>>I'm using this task as a chance to learn shell scripting.
>>
>>>Here is what I came up with. Eventually, release and reldate will be
>>>input by the user.
>>>=========================================
>>
>>>#!/usr/bin/sh
>>>release=Charlie
>>>reldate=$(date +%D)
>>>dailycode > ratemp
>>
>>>awk '
>>> ($4=release) && ($1 = reldate) { print $2 ;}
>>> 'release="$release" reldate="$reldate"
>>>ratemp
>>>==========================================
>>
>>awk -v release="$release" -v reldate="$reldate" '
>>/^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
>>relfound && $1 == reldate { print $2 }' ratemp
>>
>>Regards,
>>
>> Ed.
>
>
> Thanks for the reply Ed.
>
> I'm getting the following error msg:
>
> ./ra2.sh[11]: /^Daily /{relfound=($4==release ? 1 : 0)}^J
> relfound && $1==r
> eldate {print $2}: not found
Then your terminal copy/paste mechanism messed up and/or your editor
messed up (e.g. maybe you're using a Windows editor that's throwing in
spurious control characters as they're wont to do).
> Also, could you explain the syntax of this ($4==release ? 1 : 0)?
> Specifically, the '?' and the '1:0'
>
It's a ternary operator. See http://en.wikipedia.org/wiki/%3F:
Ed.
Re: Capturing text with Awk
am 02.10.2007 23:29:23 von Michael Tosch
mcbalagtas@yahoo.com wrote:
> On Oct 2, 12:55 pm, Ed Morton wrote:
>> mcbalag...@yahoo.com wrote:
>>> I'm trying capture a string of text generated from one script. The
>>> string will be used as input for another script.
>>> I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
>>> and the date.
>>> Here is the output file from the 1st script:
>>> Daily codes for Alpha
>>> 10/01/07 CTVGZLCS
>>> 10/02/07 5RQVGZQS
>>> 10/03/07 CP9GUMFB
>>> Daily codes for Bravo
>>> 10/01/07 MG5G2TUV
>>> 10/02/07 NTYC5KIU
>>> 10/03/07 PI4OAXJ2
>>> Daily codes for Charlie
>>> 10/01/07 ORCITFXF
>>> 10/02/07 XVST23FG
>>> 10/03/07 SWPHHNA2
>>> I'm new to shell/awk scripting. I tried the following, but the output
>>> is not correct.
>>> I think I need to grab the 3 lines under each 'release' and then
>>> filter it, but I couldn't figure that out.
>>> Any help with the logic of what I need to do would be appreciated. I'm
>>> using "Teach Yourself Shell Scripting in 24hrs" by Sriranga
>>> Veeraraghavan as my reference (as well as the internet). If there are
>>> better books, please recommend some.
>>> I'm using this task as a chance to learn shell scripting.
>>> Here is what I came up with. Eventually, release and reldate will be
>>> input by the user.
>>> =========================================
>>> #!/usr/bin/sh
>>> release=Charlie
>>> reldate=$(date +%D)
>>> dailycode > ratemp
>>> awk '
>>> ($4=release) && ($1 = reldate) { print $2 ;}
The = is an assignment.
A == is a comparison!
>>> 'release="$release" reldate="$reldate"
>>> ratemp
>>> ==========================================
>> awk -v release="$release" -v reldate="$reldate" '
>> /^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
>> relfound && $1 == reldate { print $2 }' ratemp
>>
>> Regards,
>>
>> Ed.
>
> Thanks for the reply Ed.
>
> I'm getting the following error msg:
>
> ./ra2.sh[11]: /^Daily /{relfound=($4==release ? 1 : 0)}^J
> relfound && $1==r
> eldate {print $2}: not found
Perhaps the ^J indicates a ^M at the end of the line, created by Windoze?
Remove the ^M characters!
>
> Also, could you explain the syntax of this ($4==release ? 1 : 0)?
> Specifically, the '?' and the '1:0'
>
relfound=($4==release ? 1 : 0)
is short for
if($4==release){relfound=1}else{relfound=0}
Stoneage awk's need the long form and do not have -v:
awk '
/^Daily codes/ { if($4==release){relfound=1}else{relfound=0} }
relfound!=0 && $1==reldate { print $2 }
' release="$release" reldate="$reldate" ratemp
--
Michael Tosch @ hp : com
Re: Capturing text with Awk
am 02.10.2007 23:37:57 von Ed Morton
Michael Tosch wrote:
> mcbalagtas@yahoo.com wrote:
>
>> On Oct 2, 12:55 pm, Ed Morton wrote:
>>> awk -v release="$release" -v reldate="$reldate" '
>>> /^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
>>> relfound && $1 == reldate { print $2 }' ratemp
> Stoneage awk's need the long form and do not have -v:
Right. That's one reason to use "-v", so you know for sure you aren't
using old, broken awk. If you are, then change to a reasonable awk.
Ed.
Re: Capturing text with Awk
am 03.10.2007 17:09:32 von mcbalagtas
On Oct 2, 12:55 pm, Ed Morton wrote:
> mcbalag...@yahoo.com wrote:
> > I'm trying capture a string of text generated from one script. The
> > string will be used as input for another script.
>
> > I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
> > and the date.
>
> > Here is the output file from the 1st script:
>
> > Daily codes for Alpha
> > 10/01/07 CTVGZLCS
> > 10/02/07 5RQVGZQS
> > 10/03/07 CP9GUMFB
>
> > Daily codes for Bravo
> > 10/01/07 MG5G2TUV
> > 10/02/07 NTYC5KIU
> > 10/03/07 PI4OAXJ2
>
> > Daily codes for Charlie
> > 10/01/07 ORCITFXF
> > 10/02/07 XVST23FG
> > 10/03/07 SWPHHNA2
>
> > I'm new to shell/awk scripting. I tried the following, but the output
> > is not correct.
>
> > I think I need to grab the 3 lines under each 'release' and then
> > filter it, but I couldn't figure that out.
>
> > Any help with the logic of what I need to do would be appreciated. I'm
> > using "Teach Yourself Shell Scripting in 24hrs" by Sriranga
> > Veeraraghavan as my reference (as well as the internet). If there are
> > better books, please recommend some.
>
> > I'm using this task as a chance to learn shell scripting.
>
> > Here is what I came up with. Eventually, release and reldate will be
> > input by the user.
> > =========================================
>
> > #!/usr/bin/sh
> > release=Charlie
> > reldate=$(date +%D)
> > dailycode > ratemp
>
> > awk '
> > ($4=release) && ($1 = reldate) { print $2 ;}
> > 'release="$release" reldate="$reldate"
> > ratemp
> > ==========================================
>
> awk -v release="$release" -v reldate="$reldate" '
> /^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
> relfound && $1 == reldate { print $2 }' ratemp
>
> Regards,
>
> Ed.
I'm using vi on AIX 5. When I man awk, it show the -v parameter, so I
don't think my version of awk is too old. I didn't copy/paste and I
even tried to type it in on one line w/o any returns. I still got the
same error, but w/o the ^J
/^Daily codes/{relfound=($4==release ? 1:0)} relfound && $1==reldate
{p
rint $2}: not found
Now that I think I understand what the code is doing, but I'm not sure
it is what I want.
>From my example file:
If the the release selected is 'Charlie' and todays date (reldate) is
10/02/07, I just need the code "XVST23FG". If the release was "Alpha"
and todays date (reldate) is 10/02/07, I would need "5RQVGZQS".
Re: Capturing text with Awk
am 03.10.2007 18:06:30 von Janis Papanagnou
mcbalagtas@yahoo.com wrote:
> On Oct 2, 12:55 pm, Ed Morton wrote:
>
>>mcbalag...@yahoo.com wrote:
>>
>>>I'm trying capture a string of text generated from one script. The
>>>string will be used as input for another script.
>>
>>>I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
>>>and the date.
>>
>>>Here is the output file from the 1st script:
>>
>>>Daily codes for Alpha
>>>10/01/07 CTVGZLCS
>>>10/02/07 5RQVGZQS
>>>10/03/07 CP9GUMFB
>>
>>>Daily codes for Bravo
>>>10/01/07 MG5G2TUV
>>>10/02/07 NTYC5KIU
>>>10/03/07 PI4OAXJ2
>>
>>>Daily codes for Charlie
>>>10/01/07 ORCITFXF
>>>10/02/07 XVST23FG
>>>10/03/07 SWPHHNA2
>>
>>>I'm new to shell/awk scripting. I tried the following, but the output
>>>is not correct.
>>
>>>I think I need to grab the 3 lines under each 'release' and then
>>>filter it, but I couldn't figure that out.
>>
>>>Any help with the logic of what I need to do would be appreciated. I'm
>>>using "Teach Yourself Shell Scripting in 24hrs" by Sriranga
>>>Veeraraghavan as my reference (as well as the internet). If there are
>>>better books, please recommend some.
>>
>>>I'm using this task as a chance to learn shell scripting.
>>
>>>Here is what I came up with. Eventually, release and reldate will be
>>>input by the user.
>>>=========================================
>>
>>>#!/usr/bin/sh
>>>release=Charlie
>>>reldate=$(date +%D)
>>>dailycode > ratemp
>>
>>>awk '
>>> ($4=release) && ($1 = reldate) { print $2 ;}
>>> 'release="$release" reldate="$reldate"
>>>ratemp
>>>==========================================
>>
>>awk -v release="$release" -v reldate="$reldate" '
>>/^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
>>relfound && $1 == reldate { print $2 }' ratemp
>>
>>Regards,
>>
>> Ed.
>
>
> I'm using vi on AIX 5. When I man awk, it show the -v parameter, so I
> don't think my version of awk is too old. I didn't copy/paste and I
> even tried to type it in on one line w/o any returns. I still got the
> same error, but w/o the ^J
>
> /^Daily codes/{relfound=($4==release ? 1:0)} relfound && $1==reldate
> {p
> rint $2}: not found
This looks like a shell error message which informs you that the
awk program is no known command.
Have you enclosed the program in single quotes with approriate
spaces?
Try to replace the ternary operator ?: by the code that Michael
suggested upthread.
Janis
>
> Now that I think I understand what the code is doing, but I'm not sure
> it is what I want.
>
>>From my example file:
>
> If the the release selected is 'Charlie' and todays date (reldate) is
> 10/02/07, I just need the code "XVST23FG". If the release was "Alpha"
> and todays date (reldate) is 10/02/07, I would need "5RQVGZQS".
>
Re: Capturing text with Awk
am 03.10.2007 19:51:24 von mcbalagtas
On Oct 3, 9:06 am, Janis Papanagnou
wrote:
> mcbalag...@yahoo.com wrote:
> > On Oct 2, 12:55 pm, Ed Morton wrote:
>
> >>mcbalag...@yahoo.com wrote:
>
> >>>I'm trying capture a string of text generated from one script. The
> >>>string will be used as input for another script.
>
> >>>I need to grab the 'code' based on the release (Alpha, Bravo, Charlie)
> >>>and the date.
>
> >>>Here is the output file from the 1st script:
>
> >>>Daily codes for Alpha
> >>>10/01/07 CTVGZLCS
> >>>10/02/07 5RQVGZQS
> >>>10/03/07 CP9GUMFB
>
> >>>Daily codes for Bravo
> >>>10/01/07 MG5G2TUV
> >>>10/02/07 NTYC5KIU
> >>>10/03/07 PI4OAXJ2
>
> >>>Daily codes for Charlie
> >>>10/01/07 ORCITFXF
> >>>10/02/07 XVST23FG
> >>>10/03/07 SWPHHNA2
>
> >>>I'm new to shell/awk scripting. I tried the following, but the output
> >>>is not correct.
>
> >>>I think I need to grab the 3 lines under each 'release' and then
> >>>filter it, but I couldn't figure that out.
>
> >>>Any help with the logic of what I need to do would be appreciated. I'm
> >>>using "Teach Yourself Shell Scripting in 24hrs" by Sriranga
> >>>Veeraraghavan as my reference (as well as the internet). If there are
> >>>better books, please recommend some.
>
> >>>I'm using this task as a chance to learn shell scripting.
>
> >>>Here is what I came up with. Eventually, release and reldate will be
> >>>input by the user.
> >>>=========================================
>
> >>>#!/usr/bin/sh
> >>>release=Charlie
> >>>reldate=$(date +%D)
> >>>dailycode > ratemp
>
> >>>awk '
> >>> ($4=release) && ($1 = reldate) { print $2 ;}
> >>> 'release="$release" reldate="$reldate"
> >>>ratemp
> >>>==========================================
>
> >>awk -v release="$release" -v reldate="$reldate" '
> >>/^Daily codes/ { relfound = ($4 == release ? 1 : 0) }
> >>relfound && $1 == reldate { print $2 }' ratemp
>
> >>Regards,
>
> >> Ed.
>
> > I'm using vi on AIX 5. When I man awk, it show the -v parameter, so I
> > don't think my version of awk is too old. I didn't copy/paste and I
> > even tried to type it in on one line w/o any returns. I still got the
> > same error, but w/o the ^J
>
> > /^Daily codes/{relfound=($4==release ? 1:0)} relfound && $1==reldate
> > {p
> > rint $2}: not found
>
> This looks like a shell error message which informs you that the
> awk program is no known command.
>
> Have you enclosed the program in single quotes with approriate
> spaces?
>
> Try to replace the ternary operator ?: by the code that Michael
> suggested upthread.
>
> Janis
>
>
>
> > Now that I think I understand what the code is doing, but I'm not sure
> > it is what I want.
>
> >>From my example file:
>
> > If the the release selected is 'Charlie' and todays date (reldate) is
> > 10/02/07, I just need the code "XVST23FG". If the release was "Alpha"
> > and todays date (reldate) is 10/02/07, I would need "5RQVGZQS".
I removed everything except print and awk seems to work fine:
awk '
{ print $2 ;}
' ratemp
I replaced ternary operator with Michael's coed and I still get the
same error.
Re: Capturing text with Awk
am 03.10.2007 20:16:25 von Janis Papanagnou
mcbalagtas@yahoo.com wrote:
[big snip]
> I removed everything except print and awk seems to work fine:
I had no doubt that _awk_ works fine. I doubt that _your program_
is correct.
>
> awk '
> { print $2 ;}
> ' ratemp
>
> I replaced ternary operator with Michael's coed and I still get the
> same error.
I suggest what usually helps to make apparent what's wrong; post
exactly what you typed, your script, how you called it! To repeat;
the error looks like a _shell_ error message which informs you
that the *awk* program is not a known command. Maybe you made some
quoting mistake in your shell program. If you post your script make
sure that the shell and awk commands don't get wrapped; reformat
your scripts so that each line has less than 70 columns - do that
*before* you try to run the script and post *exactly* what you've
done.
Janis
Re: Capturing text with Awk
am 03.10.2007 20:56:48 von mcbalagtas
On Oct 3, 11:16 am, Janis Papanagnou
wrote:
> mcbalag...@yahoo.com wrote:
>
> [big snip]
>
> > I removed everything except print and awk seems to work fine:
>
> I had no doubt that _awk_ works fine. I doubt that _your program_
> is correct.
>
>
>
> > awk '
> > { print $2 ;}
> > ' ratemp
>
> > I replaced ternary operator with Michael's coed and I still get the
> > same error.
>
> I suggest what usually helps to make apparent what's wrong; post
> exactly what you typed, your script, how you called it! To repeat;
> the error looks like a _shell_ error message which informs you
> that the *awk* program is not a known command. Maybe you made some
> quoting mistake in your shell program. If you post your script make
> sure that the shell and awk commands don't get wrapped; reformat
> your scripts so that each line has less than 70 columns - do that
> *before* you try to run the script and post *exactly* what you've
> done.
>
> Janis
Ok...sorry. I misunderstood.
I made some spacing corrections and that fixed the problem.
Thanks everyone for your help and patients. I would not have been able
to figure this out from reading my script book.