Ex 3.4 - Passing arguments to bash script not working (exercise)

I am stuck the Ex 3.4 where we learn about passing arguments. I don’t suppose I understand what an argument ($1, $2, $3) represent when executing a script.

I received the unary operator missing error first and someone’s already answered that query on a different thread here. I implemented the solution and now when I execute my demo.sh script, it does nothing.

Hi @shinde619nikhil,

welcome to our community.

The variables $1, $2 and $3 contains the values of the parameters that you pass to the script.

If you call your script with:

./demo.sh I love learning

Then the value of $1, $2 and $3 will I, love and learning respectively.

If your script does nothing, could it be because you are not passing any parameter?

If you still didn’t manage to solve the problem, could you paste the content of demo.sh here?

Please let us know how else we can help.

Thank you!
That was the mistake. I wasn’t actually using any arguments when running my scripts. Thanks again

1 Like