Question

In: Computer Science

Open the terminal and using vi/vim create a new script and name it lab6 Insert at...

  • Open the terminal and using vi/vim create a new script and name it lab6
  • Insert at the top of your file a comment with your name, class and section number (e.g. #John Doe, EMT 2390L - OL123).
  • In this lab you are going to display a multiplication table of a number entered by the user between 2 and 10 using a for loop and without using multiplication. The table will display the values that are less than or equal to 100.
  • Ask the user what multiplication table to display and save that value in a variable named table.
  • Validate the value of the variable table so that it is a number between 2 and 10 inclusive.
  • Using a for loop, display the values of the multiplication table of the number entered by the user in the variable table, going up to 100.
  • Save the script and make it executable (HINT: use the chmod command with mode 755).
  • Execute the script (HINT: use dot slash ./ combination, followed by your script name) and fix any errors.
  • Submit here on Blackboard your script file. DO NOT submit screen shots, ZIP files, or any other kind of file. Submission is on Blackboard ONLY. DO NOT send emails or messages, use the Blackboard link to the lab in order to submit.
  • Deadline: 10/28 at 11:59PM

Solutions

Expert Solution

Hi,

/*

NOTE: I hope in this question you need a shell script for the multiplication table till 100 between 2 and 10 inclusive.

I am assuming that you can open the terminal and create a new_script.sh using vim command and put your name, and other things asked. If there is any problem you face on this, kindly revert back to me.

For your shell script code is given below you can add this to your new_script file.

*/

Code:

#reading the number
echo "Enter a Number"
read n

# Checking for the condition

if (( $n<2 || $n>10 ))
then
#If they are not between 2 and 10 inclusive then print this
echo "Please input the values between 2 and 10 inclusive."
else

# printing the multiplication table for input value upto 100;
i=1
while [ $i -le 100 ]
do
   echo " $n x $i = `expr $n \* $i`"
   i=`expr $i + 1`
done
fi

Input and ouput with code snippet is attached below.

Firstly,

In terminal, write

chmod +x <YOUR_SCRIPT_NAME>

then excecute

./<YOUR_SCRIPT_NAME>

.

.

.

.

.

.

.

.

.

Thanks


Related Solutions

Use Vi text editor or ATOM to create a bash script file. Use the file name...
Use Vi text editor or ATOM to create a bash script file. Use the file name ayaan.sh. The script when ran it will execute the following commands all at once as script. Test your script file make sure it works. Here is the list of actions the script will do: It will create the following directory structure data2/new2/mondaynews off your home directory. inside the mondaynews, create 4 files sports.txt, baseball.txt, file1.txt and file2.txt. Make sure file1.txt and file2.txt are hidden...
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and...
Task: 2.1 : Shell Scripting Task1 :Traditional hello world script Open terminal create Lab01 directory and use cd command to move into the directory Open a new file script hello.sh using vi editor # vi hello.sh Type the following lines #!/bin/bash           echo Hello World     Save the file and return back to terminal How to Runhello.sh Adding Execute Permission Checking current permission        # ls -la hello.sh Adding Execute permission # chmod u+x hello.sh   Check whether execute permission is added # ls...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform...
Use CYGWIN TERMINAL to create this script. COPY AND PASTE the screenshot. Script 1: 1.   Perform a ls -al on the files within the user's home directory and save it to a file called ls.dat within your ~ directory 2.   Save the tree information for the /home directory in a file called tree.dat within your ~directory 3.   Create a new directory in your home directory called "backups" 4.   Move the files you just created to the new directory 5.   Rename...
Create a basic VI by using labVIEW software. Kindly share screenshot of basic VI
Create a basic VI by using labVIEW software. Kindly share screenshot of basic VI
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and save all your files for this lab into this new folder. 2. You can use any IDE (such as SciTE, NetBeans or Eclipse) or any online site (such as repl.it or onlinegdb.com) to develop your Java programs 3. All your programs must have good internal documentation. For information on internal documentation, refer to the lab guide. Problems [30 marks] Problem 1: The Account class...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and...
Objectives: 1. Create classes to model objects Instructions: 1. Create a new folder named Lab6 and save all your files for this lab into this new folder. 2. You can use any IDE (such as SciTE, NetBeans or Eclipse) or any online site (such as repl.it or onlinegdb.com) to develop your Java programs 3. All your programs must have good internal documentation. For information on internal documentation, refer to the lab guide. Problem : The Fraction class (Filename: TestFraction.java) Design...
Using Python The script is to open a given file. The user is to be asked...
Using Python The script is to open a given file. The user is to be asked what the name of the file is. The script will then open the file for processing and when done, close that file. The script will produce an output file based on the name of the input file. The output file will have the same name as the input file except that it will begin with "Analysis-". This file will be opened and closed by...
Write a bash script that... create new user ./finalProject user if a new user is to...
Write a bash script that... create new user ./finalProject user if a new user is to be created ask for the new users information and use it when creating the new user add a new printer ./finalProject printer ask anything you need in order to create the new printer (I.e. name) permissions ./finalProject permissions ask what document and permissions the user wants restarting the computer ./finalProject restart
1. How to create a group of users using a PowerShell script. 2. how to create...
1. How to create a group of users using a PowerShell script. 2. how to create a file consisting a group of 3 new user name’s and passwords, 1 to a line in power shell. 3. How to write a script in power shell to delete specific group of users. Prove that it works.
Using PowerShell ISE or VSCode, create a PowerShell script that will do the following: Create functions...
Using PowerShell ISE or VSCode, create a PowerShell script that will do the following: Create functions to get the following information Local username Local machine name Time zone Current Date Output the data that was collected to the screen Upload the script. Paste a screenshot of the results here
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT