Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

bother10.sh #!/bin/bash # # prints something to the terminal and waits, but only

ID: 3855749 • Letter: B

Question

bother10.sh

#!/bin/bash
#
# prints something to the terminal and waits, but only 10 times

count=0
while [ $count -lt 10 ]
do
   sleep 1
   echo Excuse me
   (( count += 1))
done

Note: Use Nano Please

A shell script named hw6.sh that performs the operations listed below.
This file should be in an hw6 directory inside your hw directory inside your it244 directory.
100 points

Requirements

Create an hw6 directory in your hw directory inside your it244 directory

Go to the hw6 directory and run Unix commands that will execute the steps below

When you have a command line that does what the step asks you to do, paste it into hw6.sh using nano or any other text editor

When you have completed all the steps, create an echo statement before the commands for each step, that will print the step number to the terminal

Testing

The script hw6.sh must have the format specified in this document

Scripts that do not follow the rules specified in the document mentioned above will will have points deducted from their score

Be sure to test your script and correct any errors you find

You will lose 5 points for each error that occurs when running your script

To run your script and see only the error messages run the following command

Steps for Script

1. Copy bother10.sh from /home/ghoffman/course_files/it244_files to your hw6 directory.
Run this program in the background redirecting output to /dev/null.
Be sure you copy and run bother10.sh, NOT bother.sh.

2. Run a command that shows the job number of the process running bother10.sh.

3. Run a command that shows the process ID of the process running bother10.sh.

4. Copy the script make_foo.sh from ~ghoffman/course_files/it244_files to your current directory.
Run this script.
Using touch, create the file foo.txt.
Perform a long listing of all files whose name starts with the string "foo" using meta-characters.

5. Using meta-characters, perform a long listing of all files whose name starts with the string "foo", followed by a single character, followed by .txt .

6. Using meta-characters, perform a long listing of all files whose name starts with the string "foo", followed by a single digit, either 1, 3 or 5, followed by .txt .

7. Using meta-characters, perform a long listing of all files whose name starts with the string "foo", followed by a single digit from 1 through 5 followed by .txt . Do this using the range feature of one of the meta-characters.

8. Using meta-characters, perform a long listing of all files whose name starts with the string "foo" followed by a single digit, not 1, nor 3 nor 5, followed by .txt .

9. Using meta-characters, perform a long listing of all files whose name starts with the string "foo" followed by two digits followed by .txt .

10. Using meta-characters, perform a long listing of the files foo21.txt, foo25.txt and foo29.txt. This must be done using a single command.

Explanation / Answer

//copy file and running in background Syntax : cp source destination na running it in background using( &)
1.    cp   /home/ghoffman/course_files/it244_files/bother10.sh /home/ghoffman/course_files/it244/hw6 >/dev/null 2>&1 &

// display job number of running process
2.    jobs -l    

//process id
3.    echo $!  

//copy script
4. cp   /home/ghoffman/course_files/it244_files/make_foo.sh /home/ghoffman/course_files/it244/hw6

//using touch new file
touch file.txt

// ? : used to display any single character except a leading dot
5. ls -l *foo?.txt

// foo followed by 1 or 3 or 5 and .txt
6. ls -l *foo[135].txt

// foo followed by values from 1 to 5 and .txt
7. ls -l *foo[1-5].txt

// ! : is used to exclude following digits
8. ls -l *foo[!135].txt

// foo followed by 2 digits and .txt
9. ls -l *foo[1-9][1-9].txt

// foo followed by foo21/foo25 / foo29 .txt
10. ls -l *foo[2][159].txt