Script with variable and condition

Hello

newbies question...

I just need a script able to launch a command when a condition is matched :

#!/bin/ksh
 
SIZ = 'cat /nurp/control.lst|wc -l' 
if test "$SIZ" -gt 0
then
echo 1
else 
echo 2
fi

but I receive errors messages

./t2[5]: SIZ:  not found
2

whats wrong ?
thanks for help

try sth like this..

SIZ=$(cat /nurp/control.lst|wc -l)
if [[ "$SIZ" -gt 0 ]]
then
echo 1
else
echo 2
fi

A more simple version

SIZ=$(cat /nurp/control.lst|wc -l)
[[ "$SIZ" -gt 0 ]] && echo 1 || echo 2

No need to use cat and variable SIZ:

[[ $( wc -l < infile ) -gt 0 ]] && echo 1 || echo 2

Pls use code tags as advised.
All proposals above are fine and work, but I think your ./t2[5]: SIZ: not found error comes from the two spaces around the equals-sign when defining SIZ. Remove them, test, and come back with result.

What RudiC mentioned is indeed an issue.

On top of that I see you are using single quote around the command:

'cat /nurp/control.lst|wc -l'

Replace that with:

SIZ=$( cat /nurp/control.lst|wc -l )

OR

SIZ=$( wc -l < /nurp/control.lst )