Shell Scripting for Beginners - Hint answer is not useful

Hello,
I tried answering and modifying the script and also check the hint answer at the path but doesn’t work and the hint answer location file also doesn’t give any hint as the file is same.

Details below:
Update the script to use 2 command line variables $1 and $2 for country and capital respectively. When the script is executed it should now print the country and its capital using the values passed in as command line arguments.

eg: ./print-capital.sh Nigeria Abuja should print Capital city of Nigeria is Abuja

Check

  • info_outlineHint

Check the answer file at /tmp/assets/print-capital-answer.sh

1 Like

Lab is super easy so far but this question is extremely confusing and making me beat my head to the wall… I tried almost all methods but don’t know what you are trying to ask me to do here… Can you please elaborate… And it gets more confusing when i check the hint answer where the file is same with no changes in the hint answer… then what is reason for having the answer when there is no answer but the same file… appreciate your quick response as I’m learning on a daily basis and don’t want to give a gap between learning…
Thanks -Viq

@viquar22 Can you please mention the Lab name which you are facing the issue?

Lab: Command line argument & inputs

Hi @viquar22,

Although the lab is marking my answer as incorrect, my script is running correctly. Check this out for reference:

capital_city=$1
country=$2
echo "Capital city of $2 is $1" 

Then run ./print-capital.sh Abuja Nigeria

Article:

https://findanyanswer.com/what-is-1-and-2-in-shell-script

If you run ./asdf.sh a b c d e, then $1 will be a, $2 will be b, etc. In shells with functions, $1 may serve as the first function parameter, and so forth.

Hope this helps:-)