Awk issue using int function

Hi,

I am having issue with awk command . This command is running in the command prompt but inside a shell script.

awk -F'| ' 'int($1)==$1 && int($3) ==$3' int_check.txt
$cat int_check.txt
123|abc|123x
234|def|345

When i run it inside a shell script i am getting the error

"bailing out near line no 1"

Can anyone help on this.??

Hi

Try using 'nawk' in place of 'awk'.

Guru.

# awk -F'| ' 'int($1)==$1 &&int($3)==$3' int_check.txt
awk: illegal primary in regular expression |  at
 input record number 1, file int_check.txt
 source line number 1
# awk -F'|' 'int($1)==$1 &&int($3)==$3' int_check.txt
234|def|345

Remove the extra space from FS

@guruprasad

When i try with nawk i m getting this error:
nawk: syntax error at source line 1

 context is
         >>> ${ <<<
nawk: bailing out at source line 1

Let me give extra info here.. probably it will help u to help me..

In this command

awk -F'| ' 'int($1)==$1 && int($3) ==$3' int_check.txt

the value "int($1)==$1 && int($3) ==$3" is obtained from a variable .. i am using that varaible here in the command

Something like this..

awk -F'| ' '$command' int_check.txt

---------- Post updated at 08:38 AM ---------- Previous update was at 08:14 AM ----------

[/COLOR]@danmero

Still i am getting the same error...

try this

awk -F'| ' '{int($1)==$1 && int($3) ==$3}' int_check.txt

other example is :

awk -F":" '{ print $1 $3 }' /etc/passwd

and other

{
    if ( $5 ~ /root/ ) {
        print $3
    }
}

@ jecaestevez

Hey .. I have tried the command :

 awk -F'|' '{int($1)==$1 && int($3)==$3}' int_check

I am getting teh following error

awk: syntax error near line 1
awk: illegal statement near line 1