Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a bash script that accepts a persons name as acommand-line argument and simply prints out the following greeting:Good day, ! Nice to meet you!,

  1. Write a bash script that accepts a person’s name as acommand-line argument and simply prints out the following greeting:"Good day, ! Nice to meet you!", where is a positional parameter (i.e., acommand-line argument) passed to the script. If the user does notenter a command-line argument when invoking this shell script, youwill simply output: "Hope you have a great day!", without any namedisplayed. This bash script should be called rec03A.sh.

    SAMPLE OUTPUT (input in bold):

    $ ./rec03A.sh Mark
    Good day, Mark! Nice to meet you! $ ./rec03A.sh
    Hope you have a great day!

  2. Write a bash script that (1) prompts the user to enter a Linuxcommand and reads in the user’s input, (2) prints out a meaningfulmessage with the user’s entered command to be executed, and finally(3) executes the user’s entered command. The Linux command is to beread in, not passed as a command-line argument. This bash scriptshould be called rec03B.sh.

    SAMPLE OUTPUT (input in bold):

    $ ./rec03B.sh
    Enter Linux command to perform: ls
    Command to be executed: ls
    a.out Lab01A.c Lab02B.sh minor1.c minor2.c

  3. Write a bash script that will repeatedly prompt the user toguess a random number between 1 and 10, inclusively, until the usercorrectly guesses it. To generate a random number, you can use$RANDOM, which is an internal bash function that returns apseudorandom integer in the range 0 – 32767. You can use themodulus operator to limit the range, plus an offset value so thatit’s between 1 and 10, inclusively.

Specifically, generate a random number between 1 and 10,inclusively. Then, in a loop, prompt the user to enter a numberbetween 1 and 10. If the user’s guess is correct, then print acongratulatory message with the correct number generated by the$RANDOM function. Otherwise, if the user’s guess is not correct,print out an appropriate failure message and ask the user to tryagain. You will keep prompting the user and reading the user’sguess until the user guesses the number correctly. This bash scriptshould be called rec03C.sh.

SAMPLE OUTPUT (input in bold):

$ ./rec03C.sh
Enter a number between 1 and 10: 5 Sorry, you are not correct. Tryagain! Enter a number between 1 and 10: 9 Sorry, you are notcorrect. Try again! Enter a number between 1 and 10: 2Congratulations, the number is 2.

Step by Step Solution

3.56 Rating (177 Votes )

There are 3 Steps involved in it

Step: 1

binbash Generate a random number between 1 and 10 randomnumber RAND... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Applied Regression Analysis And Other Multivariable Methods

Authors: David G. Kleinbaum, Lawrence L. Kupper, Azhar Nizam, Eli S. Rosenberg

5th Edition

1285051084, 978-1285963754, 128596375X, 978-1285051086

More Books

Students also viewed these Electrical Engineering questions

Question

Show that is one-to-one and find f(x) = J2 1 + 1 dt

Answered: 1 week ago

Question

What are three disadvantages of using the direct write-off method?

Answered: 1 week ago