Question

Write a Bash script called hello that uses command line arguments to allow the user to...

  1. Write a Bash script called hello that uses command line arguments to allow the user to put two strings after the command name, when the script is being executed. These strings should represent a first and last name. The script should then write out a greeting to the user that includes the first and last name. Here is an example of how the script might work (the first line represents what the user types to launch the script):

[user@HAL] hello John Smith             ï you type the script name followed by first and last name

Hey John Smith, nice to see you ï script writes out the greeting

To do this, you will need to use the variables $1 and $2 in your code. Remember that in a script, variables of this type represent arguments that are typed on the command line after the command’s name, when the script is launched.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

first=$1
last=$2

printf "\nHey $first $last, nice to see you\n\n"

Screenshot: ( for reference )

Output:

-----------------
Note: If you have any doubts please comment.

It will be great help If you like.

Add a comment
Know the answer?
Add Answer to:
Write a Bash script called hello that uses command line arguments to allow the user to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT