Question: Set up the script and create an input file First, create a Bash shell script that contains the following commands. Name it mod 9 .

Set up the script and create an input file
First, create a Bash shell script that contains the following commands. Name it mod9.sh.
You can copy-and-paste this code if you want to. Lines that begin with the # symbol are comment lines; it's your choice whether you want to include them inside your script file.
#!/bin/bash
# Get command-line arguments
in_file=$1
out_file=$2
# Get the first 80 characters of the input file and place
# them into the output file (note: this is the same "dd"
# command from pages 98-99 of Linux Basics for Hackers)
dd if=$in_file of=$out_file count=1 bs=80
# Append an end-of-line character to the output file
# (note: you need >>, not just >, in this case!
# > would clear the output file's old contents.)
echo '
'>> $out_file
# Send the contents of the output file to standard output
cat $out_file >/dev/stdout
# Send a confirmation message to standard error
echo 'Output file has been created.'>/dev/stderr
exit 0 # this last line isn't required, but it's good practice
Once this script is created, make it executable (chmod u+x mod9.sh is a good command for this).
Next, run the following command to create a text file that is exactly 80 characters long.
echo 'This is a text file that happens to be exactly 80 characters long. Use it well.'>./80char.txt
Create a file containing your results
Now start a new LibreOffice Write (or Word) document, or open a new text file. (The file name does not matter.) This is the only file that you need to submit on Canvas.
In the file, write what you see when you run this script with each of the following commands. You can copy output from the console into your file, or you can write English text to summarize what you can see; it's your choice.
./mod9.sh ./80char.txt ./9-1.out
./mod9.sh ./80char.txt ./9-2.out >/dev/null
./mod9.sh ./80char.txt ./9-3.out 2>/dev/null
./mod9.sh /dev/zero ./9-4.out
./mod9.sh /dev/random ./9-5.out
if this command stalls or stops working, press Ctrl+C or Command+C on your keyboard to stop the command
./mod9.sh /dev/urandom ./9-6.out
Also, answer the following two questions in your output file.
Did anything about the output from any of these commands surprise you? If so, what?
Is there anything about the script or these devices that you are confused about or that you would like to learn more about? ("No" is an acceptable answer.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!