Question

In: Computer Science

In this lab, you will learn how to create shell scripts using the Bourne Shell Scripting...

In this lab, you will learn how to create shell scripts using the Bourne Shell Scripting language. The student will have to do research on the Bourne Shell Scripting language and then writ a script that asks the First Name , Last Name, Age, and Country of origin of the student and then print out these items in a statement Then the students will write a 3 to 4-page paper (not including the title and references pages) describing how the process was carried out in the lab

Solutions

Expert Solution

#BASH Script To ask the Details of the student and then print out in a statement
echo "Enter your first name"
read FIRST
echo "Enter your last name"
read LAST
echo "Enter your Age"
read AGE
echo "Enter your Country of origin"
read COUNTRY
echo "The details of the student are:
The Full name is $FIRST $LAST,
The age of the stdent is $AGE,
The country of origin is $COUNTRY. "

The above script is run to fulfill the requirements of this question. BASH stands for Bourne-Again Shell. It has multiple variable that are responsible to pick the values which are provided by the user. The above script begins with a comment that describes the function of the script which in this case was to use Bourne Shell Scripting language to write a script that asks the First Name, Last Name,Age and Country of origin of the student and then print out these items in a statement for the user to view it.

There are a few concepts of BASH that were used here such as Comment, Variable, echo, read.The name of the variable used are $FIRST $LAST,$AGE,$COUNTRY in the script that we have written. Here we notice that we don't need to pre-define these variables in the program we declare them when we need them which is the case for most of the scripting languages. The echo command is used to display line(s) of text to the console which is considered to be the output of the code. The echo command is a built in command in the BASH shell scripting scenario. Similarly, The read command is used to read input in the form text or string or numbers which is given by the user. So basically it takes input from the keyboard. The read command is a built in command in the BASH shell scripting scenario.


Related Solutions

CIT 371 Lab 12: shell scripting Start VMware, your VM and log in as Student. cd...
CIT 371 Lab 12: shell scripting Start VMware, your VM and log in as Student. cd to your home directory and create a subdirectory called scripts. cd to that directory. You can use gedit or some other editor but you need to get used to vi, so I strongly recommend that you use vi. Remember before running any new script that you will need to modify its permissions to be executable. Use either 745 or 755. Create a script called...
Create shell scripts, each in its own .sh file. Please include a shebang line at the...
Create shell scripts, each in its own .sh file. Please include a shebang line at the top of the script as well as appropriate comments through out. Write a script that reads sunspot data from data-shell/data/sunspot.txt and uses awk to print a list of the total number of sunspots for each year on record as well as the twelve monthly averages across the record. Note: "awk allows you to index arrays using strings, so as you traverse the data file,...
Learn by Doing Matched Pairs: In this lab you will learn how to conduct a matched...
Learn by Doing Matched Pairs: In this lab you will learn how to conduct a matched pairs T-test for a population mean using StatCrunch. We will work with a data set that has historical importance in the development of the T-test. Paired T hypothesis test: μD = μ1 - μ2 : Mean of the difference between Regular seed and Kiln-dried seed H0 : μD = 0 HA : μD > 0 Hypothesis test results: Difference Mean Std. Err. DF T-Stat...
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...
this is bash scripting. a. Write a shell script that adds an extension “.deb” to all...
this is bash scripting. a. Write a shell script that adds an extension “.deb” to all the files in a directory. b. Write a command sequence or a script to insert a line “GHIJKLM” at every 10th line of a file? c. Write a bash command or script to find all the files modified in less than 5 days and print the record count of each.
The Problem Statement In this lab section, you are going to learn how to sort an...
The Problem Statement In this lab section, you are going to learn how to sort an array of integers, and to sort an array of objects. We are going to divide the work into two parts. Part 1. Sorting an array of integers using selection sort In this part, you are given the code (see List 1) for sorting an array of integers into ascending order. The sorting method used is the selection sort. You can cut-and-paste the code into...
Can you write the shell scripts for these C files (code in C): #include <stdio.h> #include...
Can you write the shell scripts for these C files (code in C): #include <stdio.h> #include <string.h> #include <ctype.h> int main(int argb, char *argv[]){ char ch; int upper=1; if(argb>1){ if(strcmp(argv[1],"-s")==0){ upper=1; } else if(strcmp(argv[1],"-w")==0){ upper=0; } } while((ch=(char)getchar())!=EOF){ if(upper){ printf("%c",toupper(ch)); } else{ printf("%c",tolower(ch)); } } return 0; } ======================================================== #include <stdio.h> #include <stdlib.h> int calcRange(int array[],int size){ int max=array[1]; int min=array[0]; int a=0; for(a=1;a<size;a++){ if(array[a]>max){ max=array[a]; } } for(a=1;a<size;a++){ if(array[a]<min){ min=array[a]; } } printf("%d-%d=%d\n",max,min,max-min); } int main(int arga, char **argv){...
Using MATLAB, Create five scripts for 5 3D polts with different views
Using MATLAB, Create five scripts for 5 3D polts with different views
In this lab you will learn how to use methods from the Math class in order...
In this lab you will learn how to use methods from the Math class in order to calculate the area or the volume of several different shapes. If you are confused about the Methods you can access from the Math class and would like to see some examples click here. Hint: Most of these methods can be done in one line. Step 1 - circleArea In this method you will calculate the area of a circle. Before you can calculate...
a. Using Matlab scripts create the following matrices (???1 and ???2) ???1 = [ 3 2...
a. Using Matlab scripts create the following matrices (???1 and ???2) ???1 = [ 3 2 −3 6 7 4 3 −6 7 ], ???2 = [ 2 1 7 3 3 9 −6 6 1 ]    b. Write code to add the second row of ???1 to the third row of ???2 and store results in the first row of ???1. c. Write code to add the second column of ???1 with the third column of ???2 and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT