Question

Programs/scripts 13. Write a bash shell script that displays the date by using the shell command date. 14. Write a command li

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

13)

The command is $date

Command execution screenshots:

R script.sh (-/Desktop) - gedit Open - save : script.shx date

ubu@ubuntu:-/Desktops bash script.sh Sat Feb 15 21:31:41 PST 2020 ubu@ubuntu:-/Desktop$ 1

14)

Shell script:

count="$1" #storing first parameter
cmd="$2" #storing second parameter
while [ $count -ne 0 ] #running in a loop
do
eval "$cmd" #executing the command
count=`expr $count - 1`
done

Screenshots:

O test.sh (-/Desktop) - gedit Open - Save Undo E test.sh count=$1 #storing first parameter cmd=$2 #storing second paramet

ubu@ubuntu:-/Desktop bash test.sh 3 date Sat Feb 15 21:55:29 PST 2020 Sat Feb 15 21:55:29 PST 2020 Sat Feb 15 21:55:30 PST 20

unixPasswd ubu@ubuntu:-/Desktop bash test.sh 3 dir 1.sh- files.tar Sample.txt test.sh compress.tar.gz hi script.sh- test.sh 1

Add a comment
Know the answer?
Add Answer to:
Programs/scripts 13. Write a bash shell script that displays the date by using the shell command...
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 shell script to print the number of command line arguments and list of...

    Write a bash shell script to print the number of command line arguments and list of command line arguments 3. 12]

  • Write a script using simple shell commands. The script takes a command line argument that specifies...

    Write a script using simple shell commands. The script takes a command line argument that specifies a directory dir. The script first changes directory to dir, then prints the following in sequence: (a) A line starting “Current date and time: ”. Then on the same line, the current time and date. (b) A line starting “Current directory is : ”. Then, on the same line, the absolute pathname of the current working directory. (c) An empty line (d) The line...

  • 1. Write 4 simple shell scripts. Each question will ask you to write one or more...

    1. Write 4 simple shell scripts. Each question will ask you to write one or more command lines to solve a problem. Put the command(s) from each problem into a file named problem1.sh, problem2.sh Note that if you want your script to be interpreted by bash, each file should start with the line: #!/bin/bash and will have one (or more, as needed) commands following it. To execute each script in bash, so you can determine if it is working or...

  • Write a bash shell script to carry out each of the following tasks: What to Do:...

    Write a bash shell script to carry out each of the following tasks: What to Do: a. Safe Delete: When you use the “rm” command in Linux, it will delete the specified files, with no chance for recovering them back later. Write a script (called srm) that will safely delete the files passed to it as command-line arguments. For example, typing the command: “srm file1 file2 file3”, the script shall not actually delete these files, but instead it shall move...

  • You are currently running/debugging a shell script program in the foreground that seems to be in an infinite loop, to terminate/kill the shell script program. 7. (type/enter - control C to send a &#3...

    You are currently running/debugging a shell script program in the foreground that seems to be in an infinite loop, to terminate/kill the shell script program. 7. (type/enter - control C to send a "program interrupt" ) or (contact the sysadmin person to kill your shell script program) 8. The UNIX/Linux exit command entered on the KORN shell command line will exit the shell session properly (best practice). [True / False] When killing a background process with the kill command you...

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

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

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