Artificial intelligent assistant

How to evaluate a variable length in shell script? I want to write a shell script, in which it will call different command according to the variable length. But I didn't figure it out yet. My unwork script is here: for i in n5 n25 if ${#i} == 2; then do python two.py n5 elif ${#i} == 3; do python three.py n25 fi How to evaluate the variable length in shell script?

You probably want:


for i in n5 n25
do
if [ ${#i} -eq 2 ]; then
python two.py n5
elif [ ${#i} -eq 3 ]; then
python three.py n25
fi
done


Note that:

* `for` goes with `do ... done`.
* `if` goes with `then ... [elif; then] ... [else; then] ... fi`.
* the integer comparisons need `-eq` (equal) instead of `=` (for strings) and are written within brackets (`if [ "$var" -eq 2 ]`, etc).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 1fd28b90d7add97de37389d71cd7f87d