Alan Johnson @acjay.com · Jan 23

In Bash, positional parameters are named $1, $2, ... but if they have more than one digit, Bash assumes that only the first digit is part of the variable, and the second digit is just a random unrelated character. Rage.

3 likes 3 replies

?

Replies

Rich Burroughs · Jan 23

Oh funny, I didn’t know that. I don’t think I ever needed to go past single digits.

Manfred · Jan 23

Isn't there a command to shift the positional parameters forward? That way $2 becomes $1, and what would be $10 now becomes $9. I might be making that up but I thought that was a thing.

Alan Johnson · Jan 25

Lesson learned: don't try to reason about it, always just use "${VAR}"