Unix file empty.. but size is greater than zero??/

Hi,

I have a file by redirecting some contents in unix shell.
Even when there is no content that is being redirected, the file size still shows greater than zero.

but even if there is no matching pattern the file APPRES has size greater than 0bytes.

awk -f AA.awk $logfile>APPRES
size=`ls -l APPRES | awk '{print $5 }'`
echo $size

output:
4

if test -s APPRES always returns true if there is no matching pattern or not.

how do i check if a file has no contents in this case

There is a content in your APPRES file, likely some newlines or similar blanks.

wc -w APPRES

should return 0 if there is nothing useful in it.

Maybe your file contains empty lines, so the file size is not zero because of the LF char ending each line.
You can compute the real file size with this command :

size=`awk -F '' 'NR { cnt+=NF } END { print cnt}' APRES`

Jean-Pierre.

thanks very much. Both the solutions work good!!