~/ learn/ comp-325/ cards/ Bourne Shell Programming II: Arithmetic, Here Documents, trap, exec, Functions
1 of 47

The counter, written both ways

The counter, written both ways

Answer

i=1 i=`expr $i + 1` echo $i i=$((i + 1)) echo $i

Both print an incremented value — 2 then 3. The second line starts a process to do it; the fourth does not.

S&K 3e ch13 §13.2; arithmetic expansion from POSIX.1-2024 §2.6.4

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/12991c80-2c3b-4a05-be66-17edbe6db71e/flashcard utf-8 LF