Lab ShellScript Instruction

The purpose of this Lab is to practice and learn basic shell script commands. Referring to the “Linux Bash Shell Script” videos as seen in our “Course Learning Resources”-folder: (The video is also stored at this LINK )
Please follow instructions outline below. As you execute, please capture the execution results (screen shots) by copy/paste into this document accordingly. Your lab results submission should be your version of this document.
Note: To view/edit Linux text file on Window OS, please use MS app. “ ” or “.
1. Downloadandextracttheexercisefilename=“Ex_Files_UaR_BashScripts”. 2. Perexercisefileabove,navigatetoits“challenges”subfolder.E.g.
Nodepad++”
CS Help, Email: tutorcs@163.com
3. Opentherelevant.shfile,learn,andmakesenseofit(youmaywanttowatchthe video again).
4. Referringtothesolutionfile:“ch2_solution.sh” —————————————————————————————– #!/bin/bash
freespace=$(df -h / | grep -E “\/$” | awk ‘{print $4}’) greentext=”\033[32m”
bold=”\033[1m”
normal=”\033[0m”
logdate=$(date +”%Y%m%d”)
logfile=”$logdate”_report.log
echo -e $bold”Quick system report for “$greentext”$HOSTNAME”$normal printf “\tSystem type:\t%s\n” $MACHTYPE
printf “\tBash Version:\t%s\n” $BASH_VERSION
printf “\tFree Space:\t%s\n” $freespace
printf “\tFiles in dir:\t%s\n” $(ls | wc -l)
printf “\tGenerated on:\t%s\n” $(date +”%m/%d/%y”) # US date format
echo -e $greentext”A summary of this info has been saved to $logfile”$normal
cat <<- EOF > $logfile
This report was automatically generated by my Bash script. It contains a brief summary of some system information.
printf “SYS:\t%s\n” $MACHTYPE >> $logfile printf “BASH:\t%s\n” $BASH_VERSION >> $logfil
程序代写 CS代考 加微信: cstutorcs
—————————————————————————————–
Make changes to the script file above, so it outputs the following additional information:
a) Current working directory
b) The system information (“uname” command).
c) The script can take 1 input argument (a Linux command, e.g. “whoami”), output the results of executing the command.
Run/execute your version of the corresponding .sh file, capture the execution result screenshot, and pasted into the document, with your succinct explanation on what it does and what changes that you make.
4) Referring to the solution file: “ch4_solution.sh” —————————————————————————————– #!/bin/bash
rand=$RANDOM
secret=${rand:0:1}
function game {
read -p “Guess a random one-digit number! ” guess
while [[ $guess != $secret ]]; do
read -p “Nope, try again! ” guess
echo “Good job, $secret is it! You’re great at guessing!”
function generate {
echo “A random number is: $rand”
echo -e “Hint: type \033[1m$0 game\033[0m for a fun diversion!” }
if [[ $1 =~ game|Game|GAME ]]; then game
Computer Science Tutoring
generate fi
—————————————————————————————–
Add the following additional features to the script.
a) If a user’s guess is a miss, inform the user to pick a higher or lower number on
the next attempt.
b) If a user enters “q | Q | Quit”, exit the script execution, with message “Good
Run/execute your version of the corresponding .sh file, capture the execution result screenshot, and pasted into the document, with your succinct explanation on what it does and what changes that you make.
• Your personalized .sh file, its execution should have no syntax error.
• If you are using “Cygwin” to do this Lab, some Linux command may not be pre-
installed. You may need to do additional command/package installation (Some command may not be supported at “Cygwin”. However, please do your best to Google search the subject, and see if it can be installed).
Submission:
Please submit to online. If that fails, email your results to: Course Teaching Assistant (TA).
The subject of the email should be: [Your StudentID, Assignment Name]