Question

Write a script using bash that accepts three arguments from the user, then prints out the...

Write a script using bash that accepts three arguments from the user, then prints out the following:

  • The name of the script
  • The value of each argument
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#!/bin/bash

# Script name is stored in the variable $0
echo "Name of script: $0"
echo "The value of each argument:"
# The first argument is stored in $1
echo "First argument: $1"
# The second argument is stored in $2
echo "Second argument: $2"
# The third argument is stored in $3
echo "Third argument: $3"

Add a comment
Know the answer?
Add Answer to:
Write a script using bash that accepts three arguments from the user, then prints out the...
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
  • Write a Bash script called hello that uses command line arguments to allow the user to...

    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...

  • Write a script using the bash shell to add new users to the system. The script...

    Write a script using the bash shell to add new users to the system. The script should read user information from a comma-delimited file (each field should be separated by a comma). The filename should be passed to the script as a command-line argument. Be sure the script contains a usage clause. The input file should contain the user information with one user per line. As the system administrator, you should determine the information necessary for each user to properly...

  • In Bash Write two scripts, 'backup.sh' and 'restore.sh' which do the following: backup.sh accepts a list...

    In Bash Write two scripts, 'backup.sh' and 'restore.sh' which do the following: backup.sh accepts a list of arguments which indicate the name o the output file and a list of files that should be backed up. Will take all of the files provided oher than the first and create a tar-ball(a tarred, gzipped file) with the name provided in the first argument. restore.sh Accepts a single filename of a tar-ball created by the script above and restores the files from...

  • I need this done ASAP. Please write a bash shell script that does the following: Prints...

    I need this done ASAP. Please write a bash shell script that does the following: Prints out how many users are logged on. This can be accomplished using who and wc. Prints out a list of currently logged on users. This can be accomplished using who, grep, regular expressions, and echo. Prints out how many processes you have running from past days, and a list of those jobs. Use `whoami` to get your username. Run ps -ef and see how...

  • This assignment will assess your ability to write bash scripts. Drop​ ​down​ ​to​ ​the​ ​root​ ​user​...

    This assignment will assess your ability to write bash scripts. Drop​ ​down​ ​to​ ​the​ ​root​ ​user​ ​using​ ​the​ ​command​ ​sudo su -.​ Write a bash script named /root/exam02.sh that does the following: Takes exactly 1 argument. If the number of arguments is not 1: Print "Exiting!" and exit with return code 40. If the number of arguments is exactly 1: Print the first argument as per the example below. Example output for your reference: The script should have the following...

  • Write a bash script question.sh that accepts one command line argument which is supposed to be...

    Write a bash script question.sh that accepts one command line argument which is supposed to be a positive integer n. The script should print all odd integers from 1 through n. Write a C or C++ program question.c(pp) to read from stdin as many integers as there are available and then print the squares of all these integers. You should test your code by “./question.sh <n> | ./question” assuming the compiled C/C++ program is question. See the following for a...

  • Problem 1 Write a BASH script to create a user account from the Linux system on...

    Problem 1 Write a BASH script to create a user account from the Linux system on which your script is run. The script should process two positional parameters. First positional parameter is supposed to be a string with a user name (e.g., user_name) Second positional parameter is supposed to be a string with a user password (e.g., user_password) In your script: Check if two positional parameters were passed to your script when it was invoked If NOT, print an appropriate...

  •  Write a Perl script that accepts exactly 2 integer arguments where the first argument must...

     Write a Perl script that accepts exactly 2 integer arguments where the first argument must be less than the second argument. The script will print a comma separated list of integers starting with the first argument up through the second argument.  The last printed value should be the second command line argument not be followed by a comma.  The script should also be able to handle the following errorsituations: o incorrect number of arguments o the first...

  • LINUX 140U Create a file named script1.sh that contains a bash script that: Accepts NO command...

    LINUX 140U Create a file named script1.sh that contains a bash script that: Accepts NO command line arguments and does NOT use the read command. I will give you no credit if your bash script includes a read command. Also, you need to have at least one for..in loop in your code even if there may be other ways to do this problem. The script will go through a list of entries in the current directory (do not process subdirectories):...

  • Write a bash script that accepts one command line argument 'a' which is an integer between 1 and 50 inclusive. I...

    Write a bash script that accepts one command line argument 'a' which is an integer between 1 and 50 inclusive. It should output a list of integers from 'a' and ending with '1' according to the following iteration rule. ( fx = x/2 if x is even; fx=3x+1 if x is odd )

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