I want to count the number of lines in a file and store it in a variable if this count is zero i hv to throw an error ...is this syntax correct , but i am not getting the desired result
I am not using -s option here as i am concerned about record count not the size
#!/bin/ksh
set $count1 = `wc -l < $DD_INDD`
echo "$count1" ///just for displaying the count
if [ $count1 -lt 1 ]; then
echo ""
echo " ERROR - FILE EMPTY "
echo ""
fi;
exit
You didn't write what error you got with your script, but there were some things like a dollar sign in front of the variable name when defining it and stuff. Also you used the variable $DD_INDD and it wasn't even defined.... So it could/should look like...
#!/bin/ksh
DD_INDD=/tmp/yourfile
count1=`wc -l < $DD_INDD`
if [[ $count1 = 0 ]]; then
echo "****************************"
echo "**** ERROR - FILE EMPTY ****"
echo "****************************"
fi
exit 0