Excluding Old Files on AWK !!!

People,

I'm sorry because my english is not very good, I'm from Brazil and I need to create shell script that exclude old files. How can I do this?

I have an AWK script that works for Unix TRU64 (DIGITAL) and the same script does not work for SUN SOLARIS 5.8.

Follows the script fragment:

ls -t -1 $EXPADMIN/.dmp.gz | awk ' {
conta = conta + 1
if ( conta > 1 )
{
i=index($0,"dmp.gz")
arquivo=substr($0,1,(i-1)) "
"
printf(" \n") >> "'$EXPADMIN'/'$arquivo'.log"
printf("======================== \n") >> "'$EXPADMIN'/'$arquivo'.log"
printf("Remove arquivos antigos: \n") >> "'$EXPADMIN'/'$arquivo'.log"
printf("======================== \n") >> "'$EXPADMIN'/'$arquivo'.log"
printf(" \n") >> "'$EXPADMIN'/'$arquivo'.log"
printf("removido o arquivo %s\n",arquivo) >> "'$EXPADMIN'/'$arquivo'.log"
comando = "rm " arquivo " 2>&1"
system(comando)
printf("%s\n",comando) >> "'$EXPADMIN'/'$arquivo'.log"
}
}'

Please help me !!!

[]'s

Alexandre Alvarenga

I am assuming that you have a shell variable $arquivo declared that your printf to $EXPADMIN/$arquivo.log will use, and not the arquivo expression that awk creates for each filename processed.

If so, then your script looks OK to me. When you run the script, what results do you get?

Try using the xpg4 version of awk - the reference will be something like /usr/bin/xpg4/awk.

I forgot to say the problem is that "system" function on AWK does not work on SOLARIS.

What happens is the AWK scripts runs without errors but the system command is not executed.