i'm puzzled....
trying to look for the pattern }"'. but the below code returns to me the message below (pattern is curley queue + dbl qt + sng qt + period)
nawk -v pat="\}\"\'\."'
{
if (match($0, pat)) {
before = substr($0,1,RSTART-1);
do {
pattern = substr($0,RSTART,RLENGTH);
printf("%s%s\n", before, pattern);
$0=substr($0, RSTART+RLENGTH)
} while (match($0, pat))
}
}' $HOME/TEMP/X1.dat >> $HOME/TEMP/X2.dat
a sample data file, please.
d.f
April 3, 2009, 10:59am
3
I'm sure its not this easy, but is it a direct cut and paste of your code?
nawk -v pat="\}\"\'\."'
It looks like the last single quote is out of place...
nawk -v pat="\}\"\'\."
sample data file:
[SIZE=2]mp itable Join_plcy_trm_plcy_sts_prty_Extract__table_ "$SCHEMA_DB"'/db2eee_cr.dbc' -select 'WITH S_PH AS (SELECT PLCY_KY,
Max(s.PLCY_EVNT_KY) as PLCY_EVNT_KY
FROM '"${Gedwschema}"'.plcy_sts s, '"${Gedwschema}"'.vhcl v
output to be 2 results
1rst result for "${Gedwschema}"'.plcy_sts
2nd result for '"${Gedwschema}"'.vhcl
[/SIZE]
The output is different though...
nawk -v pat="}\"'\." -f dan1.awk dan1.txt
I'm sure its not this easy, but is it a direct cut and paste of your code?
nawk -v pat="\}\"\'\."'
It looks like the last single quote is out of place...
nawk -v pat="\}\"\'\."
the single quote you removed at the end of the nawk line (i think ??) encapsulates the whole rest of the expression... no?
nawk -v pat="\}\"\'\."'
{
if (match($0, pat)) {
before = substr($0,1,RSTART-1);
do {
pattern = substr($0,RSTART,RLENGTH);
printf("%s%s\n", before, pattern);
$0=substr($0, RSTART+RLENGTH)
} while (match($0, pat))
}
}' $HOME/TEMP/X1.dat >> $HOME/TEMP/X2.dat
needed a space before the single quote that incapsulates all that comes after the nawk line..... i appologize..
danmauer:
i'm puzzled....
trying to look for the pattern }"'. but the below code returns to me the message below (pattern is curley queue + dbl qt + sng qt + period)
nawk -v pat="\}\"\'\." '
{
if (match($0, pat)) {
before = substr($0,1,RSTART-1);
do {
pattern = substr($0,RSTART,RLENGTH);
printf("%s%s\n", before, pattern);
$0=substr($0, RSTART+RLENGTH)
} while (match($0, pat))
}
}' $HOME/TEMP/X1.dat >> $HOME/TEMP/X2.dat
in summary: (to firm up my understanding)
1) the } doesn't need an escape backslash before it, as it's interpreted literally within the double quotes surounding the pattern.
2) there's no need of an escape backslash before the single quote.... if withing the double quotes surrounding the pattern ---- i'll will take note of that.
here's a little bit better regex pat - you can remove the 'before' part in the 'printf' to get what you actually want:
nawk -v pat="'\"[^ ][^ ]*}\"'\.[^ ][^ ]*" -f dan1.awk dan1.txt
just to firm up my understanding...
below pattern means:
Single quote + none or any number of non-spaces before } + } + double quote + single quote + period + none or any number of non-spaces before � + double quotes
Thanks again for your time and patience.