Question

UNIX Write and run a simple shell script name mymenu that creates a simple command menu....

UNIX

Write and run a simple shell script name mymenu that creates a simple command menu. The script should present menu items (see below), prompts the user for a selection, and then executes the appropriate command selected. [Submit your script and the results of a test case for a, b, c, and d selections]    

COMMAND MENU

a. Current date and time

b. Name of the working directory

c. Contents of the working directory

Enter a, b, or c:

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

Hi,

I have provided the bash script below. Feel free to comment if you have any difficulties in understanding any part of the code.

#!/bin/bash
echo COMMAND MENU
echo
echo a. Current date and time
echo b. Name of the working directory
echo c. Contents of the working directory
echo
echo Enter a, b, or c:
  
read userInput

if [ $userInput = $"a" ]
then
date
fi

if [ $userInput = $"b" ]
then
printf '%s\n' "${PWD##*/}"
fi

if [ $userInput = $"c" ]
then
ls
fi

Sample output

Hope it helps!

Add a comment
Know the answer?
Add Answer to:
UNIX Write and run a simple shell script name mymenu that creates a simple command menu....
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
  • SHELL SCRIPT: Provide the following questions with the codes and command line Problem 5: Take 5...

    SHELL SCRIPT: Provide the following questions with the codes and command line Problem 5: Take 5 input arguments in a for loop, but only add the even i values to sum and display the result. Problem 6: Write a shell script that accepts path of the directory and returns a count of all the files within the specified directory. (Hint: use alias to perform cd operation) Problem 7: Write a shell script that takes an ‘count’ value as an input...

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

  • Explain what the following UNIX command does: Is 'echo I.txt' Please type shell commands (for Windows....

    Explain what the following UNIX command does: Is 'echo I.txt' Please type shell commands (for Windows. UNIX, or any other system that you like) for: creating a directory called hello world list the contents of this directory create a file called iwashere.txt display the contents of the file iwashere.txt from the command-line Please write a simple program in C for accepting a string from the command-line, reversing and printing the reversed string to standard output.

  • Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell...

    Unix questions, i need help on Hint: Commands to study to answer this question: predefined shell variables, and .profile script file, echo SHELL, HOME, PATH, MAIL and TERM are predefined shell variables. You can use the value of a shell variable in a shell command putting $ in front of it. For example, to display the value of the HOME directory of the user, specify $HOME in the echo command like echo $HOME. Do not give just the value of...

  • When you run a UNIX command where does the shell get the list of directories to...

    When you run a UNIX command where does the shell get the list of directories to search for the command that you entered? A. From the user B. From the command C. From the PATH variable D. From the kernel

  • QUESTION 1 What will be the output of following Unix command: find / -name ‘*’ A....

    QUESTION 1 What will be the output of following Unix command: find / -name ‘*’ A. List all files and directories recursively starting from / B. List a file names * in / C. List all files in / directory D. List all files and directories in / directory QUESTION 2 Which command is used to extract a column/field from a text file / input. A. paste B. get C. cut D. tar QUESTION 3 Which command creates an empty...

  • UNIX QUESTION Exercise #1. [8 Marks] Create a script that does the following: a. Takes 4...

    UNIX QUESTION Exercise #1. [8 Marks] Create a script that does the following: a. Takes 4 input parameters b. Using the shell special variables print the following: i. The command you executed ii. First input iii. Second input iv. Third input v. Fourth Input vi. Process Id vii. Total number of input parameters [ by querying the system for it ] Exercise #2. [8 Marks] Creates a script that does the following: a. Takes two input parameters b. Using the...

  • Revision Question 3 on Linux. Please explain the shell script commands in the context of post...

    Revision Question 3 on Linux. Please explain the shell script commands in the context of post execution. You have just logged in and have a directory called "novel" in your home directory containing the following files: chapter1.docx chapter2.docx chapter3.docx draft.pdf save where "save" is itself a directory and contains the files Attributes.txt draft.pdf.1 draft.pdf.2 draft.pdf.3 indexA.txt indexB.txt list1.txt list2.txt a) Describe the results you would expect when executing the following shell commands: i) ls novel/save/*A* ii) ls novel/*r[23]* iii) rmdir...

  • Objective : Write a C Shell script which copies all files(*.java and *.class) from your home dire...

    Objective : Write a C Shell script which copies all files(*.java and *.class) from your home directory to a new one, and Analyze the new directory information such as number of files, user permissions, and disk usage. Sample Output:                                                    << CS Directory Analysis >>      Date:   ============================================================ Current Directory: /home/tomss New Directory Created : /home/tomss/pgm01 File information Total Number of files : 22 files Directory files:   0 files Plain text files:   10 files File have read permissions: 3 files File have...

  • Creating a Shell Interface Using Java This project consists of modifying a Java program so that...

    Creating a Shell Interface Using Java This project consists of modifying a Java program so that it serves as a shell interface that accepts user commands and then executes each command in a separate process external to the Java virtual machine. Overview A shell interface provides the user with a prompt, after which the user enters the next command. The example below illustrates the prompt jsh> and the user’s next command: cat Prog.java. This command displays the file Prog.java on...

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