bash if Basic flow of control statement. && and || are useful when test/result is simple. But for more complex choices, the if statement exists.
basic if structures Simple if
#!/bin/bash
linecheck ()
{
if [ -f "$1" ]
then
#lc=`wc -l $1 | cut -d" " -f 1`
#echo $lc
if [ "`wc -l $1 | cut -d" " -f 1`" -gt 20 ]
then
echo "$1 has enough lines"
else
echo "$1 doesn't have enough lines"
fi
else
echo "$1 does not exist"
fi
}
|
linecheck file