New to shellscripting error: ./emailnotifications.sh: line 43: [: FH: integer expression expected

Hi ,
I'm a beginner in unix shell scripting need help in rectifying an error

Source file :test.txt with
Header
------
-----
Trailer
ex:

FH201010250030170000000000000000
abc def jke
abr ded etf
FE2

I was validating whether the header begin with FH or trailer begin with FE and sending an e-mail accordingly
I wrote a shell script but it's giving me an error saying

./emailnotifications.sh: line 43: [: FH: integer expression expected
./emailnotifications.sh: line 48: [: FE: integer expression expected

Please help me out

shell script:

src_mercury_dir="/home/dsadm/larc/scripts"
src_radiant_dir="/home/dsadm/larc/scripts"

cd $src_mercury_dir;
file1="/home/dsadm/larc/scripts/Mercury_LARC.txt"
cd $src_radiant_dir;
file2="/home/dsadm/larc/scripts/3URADIANRAD_LS.txt"

echo $file1;
echo $file2;


a="FH"
b="FE"

s=`head -1 $file1 | cut -b-2`
t=`tail -1 $file1 | cut -b-2`

echo "A="$a;

echo "B="$b;

echo "S="$s;

echo "T="$t;



if [ $s -ne $a ]
then
   mail -s "No header " abc@dvcom <dev/null;
   exit;
else
 if [ $t -ne $b ]
   then
      mail -s "No trailer " abc@dv.com <dev/null;
      exit;
 else
      mail -s "HEADER TRAILER PRESENT" abc@dv.com </dev/null;

   fi
fi

please help me out

Your problem is with your if statements the operator -ne is for numeric values not string comparison use this instead:

if [ "$s" = "$a" ]
then
    mail -s "No header " abc@dvcom <dev/null;
exit;
else
if [ "$t" = "$b" ]
then

Also when posting code please put between

```text
 and 
```

tags to keep formatting.

:slight_smile:

Thanks