Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Purpose: Learn how to write basic shell script. In Chapter 2 and 3, you have learned a list of utilities. However, each time we could

image text in transcribedimage text in transcribed

Purpose: Learn how to write basic shell script. In Chapter 2 and 3, you have learned a list of utilities. However, each time we could only type a single command on command line in terminal. It is inconvenient sometimes when a task has to been accomplished by multiple commands. For example, if the task needs to be repeated, you may have to restart the execution of the list of commands by typing the command one by one. For this reason, the shell script file is used to store the commands interpreted by shell. It is more than a regular file containing only the command. You can even write for loop, if else and switch case statement in the shell script. The shell script file can be executed directly by providing the name of it on command line. Part 1: Now it is your turn to create your first shell script file by following the steps below. Step 1: Go to your home directory and create a new file named as simple.sh (vi simple.sh or nano simple.sh), then include following lines in your simple.sh. \#/bin/bash \#Simple script \# echo Congratulations! Now you know shell script! echo -n "The current time and date are: " date Step 2: Save your file and exit editor. Step 3: Execute this file by invoking its name. \$ simple.sh Question 1): What did you see in the output of step 3 ? Step 4: Execute this file by adding ./ before the its name. $./ simple.sh Question 2). What did you see in the output of step 4 ? Step 5: Try following command to make simple.sh executable. \$chmod a+x simple.sh Step 6: Execute this file again. $./simple.sh Note: you must type d before the name. This is because current working directory is not in PATH. However, you can modify the value of PATH variable and add current working directory into it by referring to next part. Question 3): Attach a screenshot of the output in step 6. Question 4): Describe the meaning of -n option in echo command. Read the slides \#13 in Chapter 4 and then answer the following two questions. Question 5): Is "Simple Script" a comment? If not, what is the meaning of it or why we use it? Question 6): Is "\#!/bin/bash" a comment? If not, what is the meaning of it or why we use it in first line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

5. What information would the team members need?

Answered: 1 week ago

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago