print remaining file after a condition is satisfied

Hi ,

could any one suggest me that how to determine if the first field is numeric and if it is greater than another number then from that point everything else should be printed using awk.

I have tried this
:

awk  -v xxxx=$xxxxx '
BEGIN {
enable=0
}
{
print $1
if ( ( $1 !~ "^[0-9][0-9]*$"  || ( $1 ~ "^[0-9][0-9]*$" && $1 <  xxxx ) )  )
{  continue }
else
enable=1

if ( enable == 1)
print $0
 }' res >res1
awk -v enable=0 -v xxxx=$xxxx ' enable != 1 && $1 ~ "^[0-9][0-9]*$" && $1 > xxxx { enable=1} enable ' file

Thanks, It is working fine from command line, but when i put it in a script it gives me this error and also, could you please let me know the last "enable" why have you used it????

3284 is the value of the variable $xxxx

The awk command is valid.
Show us your script.

Another way to do the work with awk :

awk -v xxxx=$xxxx ' ($1 ~ "^[0-9][0-9]*$" && $1 > xxxx),0 ' file

Jean-Pierre.

Jean-peirre,

sorry, but your solution doesnt work. it is printing all the lines. Anbu's solution worked fine. regarding the error, I was passing incorrect parameter. Now i have managed to solve it. Anyways, Do you mind explaining me your solution and Anbu's solution????

I am working on AIX, and the command works fine :

$ cat file
AAAAA Not printed
099   Not printed
101   Printed 1
102   Printed 2
XXX   Printed 3 and last
$ xxxx=100
$ awk -v xxxx=$xxxx ' ($1 ~ "^[0-9][0-9]*$" && $1 > xxxx),0 ' file
101   Printed 1
102   Printed 2
XXX   Printed 3 and last
$

When the pattern in in the form of pattern1,pattern2, action is performed on every record starting whith the record that matches the first pattern pattern1, and continuing throught and including the record that matches the second pattern pattern2.

pattern1 -> ($1 ~ "^[0-9][0-9]*$" && $1 > xxxx)
pattern2 -> 0 Is equivalent To 'End Of File' since 0 is considered as false by awk.

awk -v enable=0 -v xxxx=$xxxx ' enable != 1 && $1 ~ "^[0-9][0-9]*$" && $1 > xxxx { enable=1} enable ' file

enable != 1 && $1 ~ "^[0-9][0-9]*$" && $1 > xxxx { enable=1}
If a valid record have not been found (enable!=1) and if the current record is valid (tests on field $1), memorize valid record found (enable=1) so from this point all records must be printed.

enable
Test if a valid record have been found (false if enable==0, true otherwise).
The default action is 'print $0'

Jean-Pierre.