#!/bin/ksh
a =`grep MAJOR filename | tail`
if [ $a -eq 0 ]
echo " "
else
echo " $a "
fi
filename is like alarmlog file which had alarms in it i am trying to grep the mejor alrms from the file.if there are any major alarms i have to print them else nothing.
its giving me a syntax error.
./p.sh[3]: a: not found
./p.sh[5]: syntax error at line 10 : `else' unexpected
Remove the space between the variable `a' and the `='
The `if' statement is missing the `then'
Remove the spaces between " and variable a in `echo " $a "'
The quotes are recommended, the parenthesis are doing nothing.
| tail|wc -l)
tail displays ten lines by default if exist in the file, therefore wc -l return a 10 line or less, always, even if there are more.
tail is not necessary there.
echo " $Alarms "
Are you aware you're adding literal spaces in front and after any value that $Alarms holds?
thank you for reply but i tried this as well it gives me an error
a=`grep MAJOR /file../../alarm.log* | wc `
if [ $a != " " ]
then
echo ' $a '
fi
./f1.sh[4]: :=: unknown test operator
---------- Post updated at 01:40 AM ---------- Previous update was at 01:31 AM ----------
i have used code tags this is not whats in the original file i have used code tags after the first warning.if you want i can poaste exactly whats in the original file.should i be doing that to prve u wrong