1833681 Members
4698 Online
110062 Solutions
New Discussion

awk script problem :(

 
Aravind_3
Frequent Advisor

awk script problem :(

With the following awk script
______________________________________________
awk '
{
if ( $0 ~ /^product$/ ) {
getline line
if (match (line,"tag ${1}")) {
while (( getline line > 0 ) && (match line,"state configured") == 0 )) {
if (match (line,"fileset"))
{
while (match (line,"state configured") == 0 ) {
getline line
}
}
}
} else {
printf ("product\n")
print line
}
}
else
{ print }
}' /abc/INDEX > /abc/NewINDEX

______________________________________________

I am getting the following error :
_______________________________________________
awk: There is a regular expression error.
?, *, or + not preceded by valid regular expression
The source line number is 5.
The error context is
if (match (line,"tag >>> ${1}") <<<
______________________________________________

Someone help me please...

Thanks
Aravind
1 REPLY 1
Christian Gebhardt
Honored Contributor

Re: awk script problem :(

Hi
I don't know exactly what this script does ;-) but there are two errors:

awk '
{
if ( $0 ~ /^product$/ ) {
getline line
if (match (line,"tag \${1}")) {
while (( getline line > 0 ) && (match (line,"state configured") == 0 )) {
if (match (line,"fileset"))
{
while (match (line,"state configured") == 0 ) {
getline line
}
}
}
} else {
printf ("product\n")
print line
}
}
else
{ print }
}' /abc/INDEX > /abc/NewINDEX

look at line 5 :
if (match (line,"tag \${1}")) {
and line 6
while (( getline line > 0 ) && (match (line,"state configured") == 0 )) {


Chris