temporary_user_name
temporary_user_name

Reputation: 37018

Why doesn't ${#$2} work?

I have this line in a small bash function:

if [ ${#$2} -lt 25 ]; then

But it gives me Bad substitution on the ${#$2}. What am I doing wrong there? I'm trying to get the length in characters of the second command line argument. How can I do this?

Upvotes: 2

Views: 90

Answers (1)

chepner
chepner

Reputation: 530940

The parameter name is 2, not $2.

if [ ${#2} -lt 25 ]; then

Upvotes: 4

Related Questions