I could not find any references related to what does ${#} actually means in shell scripting, My rough guess is that it means the last variable passed to an invocation, but not completely sure.
Asked
Active
Viewed 134 times
2
-
Possibly useful: https://unix.stackexchange.com/q/218270/315749 (and https://unix.stackexchange.com/q/4899/315749 if you are wondering about `${#}` v. `$#`) – fra-san Mar 19 '21 at 10:50
1 Answers
3
No, it means number of positional parameters, the same as $#. For example the following script.sh
#!/usr/bin/env sh
echo ${#}
would print:
$ ./script.sh arg1 arg2 arg3
3
$ ./script.sh arg1 arg2 arg3 arg4
4
Stephen Kitt
- 411,918
- 54
- 1,065
- 1,164
Arkadiusz Drabczyk
- 25,049
- 5
- 53
- 68