I am totally new to shell scripting. Its my first hands on. I have a script where there are 4 txt files in a path and I am getting the last line from the files which are numbers but when I try to add, it gives "expr:non numeric arguments". My script contains the following script.
one=filename1.txt
count1=$(tail -1 $one| cut -c 3-)
echo $count1
two=filename2.txt
count2=$(tail -1 $two| cut -c 3-)
echo $count2
three=filename3.txt
count3=$(tail -1 $three| cut -c 3-)
echo $count3
four=filename4.txt
count4=$(tail -1 $four| cut -c 3-)
echo $count4
totalCount=`expr $count1 + $count2 + $count3 + $count4`
The text files are a large text files where the last line is always a footer for example File1.txt has FT001886157, file2.txt has FT002689634, file3.txt has FT002372958, file4.txt has FT001516254 and my output is
001886157
002689634
002372958
001516254
expr: non-numeric argument