Question

In: Computer Science

In this assignment, you are required to write a Bash script, call it assignment2.sh. Your Bash...

In this assignment, you are required to write a Bash script, call it assignment2.sh. Your Bash script has to accept at least four input arguments, and must:

1) Print to the user a set of instructions explaining how the PATH variable can be used in Bash.

2) Save the manual of the 'awk' command in the file /tmp/help.txt.

3) Shut down your Ubuntu box at 2 o'clock tonight.

4) Store your name and your partner's name in a text file inside your home directory. The name of the file must have the following format: ite404-<date>.txt, where <date> is the current date; e.g. ite404-2020-10-26.txt.

Solutions

Expert Solution

Hello learner,

Thanks for asking.

In this assignment, at first create a bash file using any editor like vi and then type the script as required after comming into the insert mode by " i ".

After that save the the script and exit by using " esc " and " :wq! ".

The command used of the terminal is

$ vi assignment2.sh

press " i " for insert mode

then type the script :-

echo " PATH is a type of  environment variable that keeps track of certain directories of the linux and by default the varibale locations are given as

  • /usr/bin
  • /usr/sbin
  • /usr/local/bin
  • /usr/local/sbin
  • /bin
  • /sbin

And to see about the directories which are currently registered under PATH, the command used is

$ echo $PATH

In bash, the PATH variable is very important. Any program in bash that runs through the bash session inherits the variable,that's why it is important that PATH includes only the necessary directories.

To see all the environment variables for bash, run this command.

$ env | sort

This the required instruction about path varable "

#To save the manual of the 'awk' command in the file /tmp/help.txt

man awk >  /tmp/help.txt.

#  To shut down your Ubuntu box at 2 o'clock tonight.

sudo crontab -e

00 02 * * * shutdown

# Store your name and your partner's name in a text file inside your home directory.

touch  ite404-2020-10-26.txt

echo "my_name my_partner_name " > ite404-2020-10-26.txt

now press " esc " and :wq! to save and exit the file.

For the execution of file the command used is

$ chmod +x assignment2.sh

$ ./assignment2.sh

In the above script echo is used for show the text from the file on the terminal.

">" this is append mode used to append the ouput any command in any file and also used in above script.

At last crontab is used to set the time for shut down and format for time used is

min     Minute field    0 to 59
hour     Hour field      0 to 23
dom     Day of Month    1-31
mon      Month field     1-12
dow      Day Of Week     0-6

and " * " is used for everyday.

please upvote and ask if you have any query.


Related Solutions

Write a bash script that will allow you to: Read in your Your name Course name...
Write a bash script that will allow you to: Read in your Your name Course name and Instructor’s name Then prompt the user to enter two numbers and determine which number is greater. Ex: If 10 is entered for the first number and 3 for the second, you should output Your name Course name Instructor’s name 10 is greater than 3. If 33 is entered for the first number and 100 for the second, you shou output Your name Course...
Assignment Write a network diagnostics bash script that does the following: Finds the IPv4 address of...
Assignment Write a network diagnostics bash script that does the following: Finds the IPv4 address of the default gateway on your machine (one way to get this is the 'default' entry, also shown as 0.0.0.0, in the output of 'ip route') and runs a ping (with a count of 5 pings) to it. Runs another count of 5 pings to the site example.com. Outputs a 1-line summary of interfaces on your machine, not including the loopback address (lo). Outputs a...
Fully Functional Script written in BASH In this section, you will write a fully functional script...
Fully Functional Script written in BASH In this section, you will write a fully functional script to help your manager with an important project that will build upon what you learned from your script work in Milestone Four. After you have written the script, you will execute it to generate a report for all three users (once for Bob, once for Henry, and once for Frank). You should have three unique generated reports in your ~/scripts directory (or more if...
Program in Bash: Write a program using bash script that can read a file from the...
Program in Bash: Write a program using bash script that can read a file from the same directory, sort the nonrepeating integers from 0-9 from smallest to largest, and output the results on the same line. Do not use the sort function.
Program in Bash: Write a program using bash script that can read a file from the...
Program in Bash: Write a program using bash script that can read a file from the same directory, sort the nonrepeating integers from 0-9 from smallest to largest, and output the results on the same line. Do not use the sort function.
Write a short bash program that aligns with the below functionality. $ sh ~/cs210_list.sh Error: missing...
Write a short bash program that aligns with the below functionality. $ sh ~/cs210_list.sh Error: missing argument $ echo $? 1 $ sh ~/cs210_list.sh /non-exist Error: ‘/non-exist’ is an invalid directory $ echo $? 1 $ sh ~/cs210_list.sh /etc File: aavark File: aabbb Size: 16 File: aaacccc File: aaaaddd Size: 1585 File: aliases~ Size: 1686 File: aliases.db Size: 12288 ... Notice: It error checks that the first argument exists and is a directory. It generates an error message and returns...
Bash script: Create a bash script that takes numbers as parameters, calculates sum and prints the...
Bash script: Create a bash script that takes numbers as parameters, calculates sum and prints the result. If no parameters passed, prompt a user (only one time) to enter numbers to sum and print the result. Submit your program as LastName_FirstName.sh file.
Linux Sign into your lab account Write a bash shell script that does the following: Print...
Linux Sign into your lab account Write a bash shell script that does the following: Print out a friendly welcome message Ask the user for the name of their favorite animal Grep that animal from a text file noises.txt Tell the user what that animal says (i.e. what noise does it make) If the animal does not exist ask the user what noise the animal makes Store that new information in noises.txt
⦁   Write a Bash script that prompts for user input and reads a string of text...
⦁   Write a Bash script that prompts for user input and reads a string of text from the user. If the user enters a no null (no empty) string, the script should prompt the user to re-enter again the string; otherwise should display the string entered “. ⦁   Given an array of the following four integers (3, 5, 13, 14); write a Bash script to display the second and all elements in the array.    ⦁   Write a short Bas...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT