Hello All,
I am running the below code in my script. I want if jk is empty nothing should be appened to the file total_usage.
but apparently its not happening.Kindy let me know how to do it.
###################################
jk=`ps auxf |grep -w $inputline|tr -s " "|cut -d " " -f1-|sort -nr -k5|grep -v root|grep -v grep`
if [ -z "$jk" ]
then
echo "Its OK"
# sed -e "/$tool/d" -e '/^$/d' total_usage>>total_usage
# sed -e "/$tool/d" total_usage>>total_usage
else
if [ $j -eq 0 ]
then
echo -e "\n$tool\n">>total_usage
ps auxf |grep -w $inputline|tr -s " "|cut -d " " -f1-|sort -nr -k5|grep -v root|grep -v grep>>total_usage
j=`expr $j + 1`
else
ps auxf |grep -w $inputline|tr -s " "|cut -d " " -f1-|sort -nr -k5|grep -v root|grep -v grep>>total_usage
fi
fi
###################################
Regards
Ankit