The $1 is a positional variable. So if you run ./script.sh arg1 $1 would be arg1 in that example, $0 would be the ./script.sh. It’s the simplest way to pass an argument to a script.
So… huh? What role does this play, since all the lines in the picture have $1? If you run it with arg1, won’t it run them all? And if you left out arg1 and also didn’t add $1 to each line, wouldn’t it also just run all of them?
The
$1is a positional variable. So if you run./script.sh arg1$1 would be arg1 in that example, $0 would be the ./script.sh. It’s the simplest way to pass an argument to a script.So… huh? What role does this play, since all the lines in the picture have $1? If you run it with arg1, won’t it run them all? And if you left out arg1 and also didn’t add $1 to each line, wouldn’t it also just run all of them?