Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Use vi to create the following script. Call the file scriptl. When completed, change the permissions to 745. Run the script by typing ./scriptl
1. Use vi to create the following script. Call the file scriptl. When completed, change the permissions to 745. Run the script by typing ./scriptl # ! /bin/bash echo You are ?USER echo Your home directory is $HOME echo Your home directory consists of 'du -sH ~ Alter your script so the output of each echo statement is redirected to the file info.txt. How did you do this? 2. Use vi to create the following script, calling it script2. When completed, change the permissions and run it. # ! /bin/bash echo What is your name? read NAME echo What is your username? read USERNAME echo Hello $NAME, your home directory contents and size: Complete this script by adding instructions to output this user's home directory contents assuming that the user's home directory will be /home/SUSERNAME as well as using the du statement from scriptl to output the disk usage of the user's home directory 3. Rewrite the script from #2 so that the NAME and USERNAME are supplied to the script by parameters and remove the first four instructions (the first two echo and the two read statements). Save and test your script. 4. Write the following script, calling the file script4. Change its permissions appropriately # ! /bin/bash if [ $# -ne 2 ]; then echo Illegal input elif [ ?1 -gt $2 ]; then echo $1 is greater else echo $2 is greater fi Save and run the script providing it no parameters, two parameters of 5 and 10, two parameters of 10 and 5, and two parameters of 5 and 5 . What does [ $#-ne 2 ] mean? Do we need this in the script? Show how you would alter the script so that it can also output if the two parameters are the same. 1. Use vi to create the following script. Call the file scriptl. When completed, change the permissions to 745. Run the script by typing ./scriptl # ! /bin/bash echo You are ?USER echo Your home directory is $HOME echo Your home directory consists of 'du -sH ~ Alter your script so the output of each echo statement is redirected to the file info.txt. How did you do this? 2. Use vi to create the following script, calling it script2. When completed, change the permissions and run it. # ! /bin/bash echo What is your name? read NAME echo What is your username? read USERNAME echo Hello $NAME, your home directory contents and size: Complete this script by adding instructions to output this user's home directory contents assuming that the user's home directory will be /home/SUSERNAME as well as using the du statement from scriptl to output the disk usage of the user's home directory 3. Rewrite the script from #2 so that the NAME and USERNAME are supplied to the script by parameters and remove the first four instructions (the first two echo and the two read statements). Save and test your script. 4. Write the following script, calling the file script4. Change its permissions appropriately # ! /bin/bash if [ $# -ne 2 ]; then echo Illegal input elif [ ?1 -gt $2 ]; then echo $1 is greater else echo $2 is greater fi Save and run the script providing it no parameters, two parameters of 5 and 10, two parameters of 10 and 5, and two parameters of 5 and 5 . What does [ $#-ne 2 ] mean? Do we need this in the script? Show how you would alter the script so that it can also output if the two parameters are the same
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started