In: Computer Science
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.
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
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.