I want to extract a number from a string and use that number for future calculations
while IFS= read line ; do
if [[ "$line" == Content-Length* ]]
then
size=$(echo "$line" | awk '{print $2}')
echo "$size"
let size=$size+1
echo "$size"
break
fi
done <files
files has the line
Content-Length: 4806
but output looks like this
4806
+1")syntax error: invalid arithmetic operator (error token is "
4806
i tried this for more than 5 hrs but could find why is this happening .can some one tell me why
$lineto end with a carriage return (\r). This carriage return winds up in the value ofsize, which theletstatement chokes on. Notice the odd error where the text following$sizeappears at the beginning of the error message, not the end. The actual error token is4806\r+1.\r+1. Too late to edit the comment).