-3
set 10 20 30 40 50

Enter the value of the variable $#:

I understand that the variables $1=10 $2=20 and so on

steeldriver
  • 81,074

2 Answers2

2

In POSIX shells, the value of special built-in variable $# corresponds to the number of positional parameters set. Ex.:

Set $1, $2, and $3 and set "$#" to 3:

set c a b

From The Open Group Base Specifications Issue 6

steeldriver
  • 81,074
-1

$# is the number of arguments $* are the arguments $@ are the arguments

Look at this

#!/bin/sh
set 1 2 3 4
echo "we had $# args"
echo Arguments are  $@ using echo '$@'
echo Arguments are  $* using echo '$*'
elbarna
  • 12,695