I have a file test.csv
with numbers:
>cat test.csv
32
23
45
I store the first value in a variable:
>e=$(cat test.csv | head -n 1)
>echo $e
32
However, I can't do arithmetic with this number, I have tried converting it to integer as explained here:
>echo "$((e + 1))"
")syntax error: invalid arithmetic operator (error token is "
EDIT: Issue might have to do with whitespaces, that I can't delete:
>c="32"
>echo $c | wc -c
3
>echo $c | wc -c
4
>echo $c | tr -d '[:space]' | wc -c
4