: + : more tokens expected

Hello-

Trying to add two numbers in a ksh shell scripts and i get this error every time I execute

stat1_ex.ksh[40]: + : more tokens expected

stat1=`cat .stat1a.tmp | cut -f2 -d" "`
stat2=`cat .stat2a.tmp | cut -f2 -d" "`

j=$(($stat1 + $stat2))  # < Here a the like the errors out
echo $j

Tried may combinations but nothing really worked, and I would like to see how to do this without invoking awk or bc

Thanks for your help.

Nomaad

It would help if you provided examples of stat1a.tmp and stat2a.tmp

the files contain one line each; basically the output of the `wc-l somefile`

65579681 ./pmroot/TgtFiles/ppax5.dat

Thanks for your help

The number of spaces in the sample you posted didn't match what you are trying with the cut command. There may or may not be multiple spaces to pad the number to some specific length so it would probably be better to simply pick out the first non-space token from that.

j=((`awk '{print $1}' .stat1a.tmp` + `awk '{print $1}' .stat2a.tmp`))

If you have control over how those files are generated in the first place, it would perhaps be better if they simply didn't contain the file name. Or do you need it for other reasons?

wc -l <./pmroot/TgtFiles/ppax5.dat>.stat1a.tmp

Note the input redirection; wc simply prints the number, no file name, when invoked on standard input.

As a side remark on coding style, the cat isn't really necessary in your original code; cut accepts a file name argument, too:

cut -d" " -f2 .stat1a.tmp