Test command in UNIX

Hi Team,

-rwxr-xr-x    1 kmani00  system            9 Nov 08 03:29 tempfile.txt
-rwxrwxrwx    1 kmani00  devgrp            0 Nov 08 03:32 testfile.txt

by exec the following command, i did not get any output.

> test -s tempfile.txt
> a=`test -s tempfile.txt`
> echo $a

>

by exec the following command, i did not get any output.

> test -s testfile.txt
> b=`test -s testfile.txt`
> echo $b

>

Not sure how this command works. How can i test the condition.

Can anyone help me out?

Thanks
Krishna

if [ -s inputfile.txt ]; then echo "size is greater than zero"; else echo "size is not zero"; fi

Try something like this...codetag please

if file exists and its size is greater than zero then print 0 else print 1

test -s file && echo "$? True" || echo "$? False"

The test command does not output anything. It returns either TRUE or FALSE via its exit code, with 0 being TRUE and 1 being FALSE.

Thank you all for your reply.

Thank you so much.

Krishna