Enter the following script named savefiles, and give yourself execute permission to the file:
$ cat savefiles
#! /bin/bash
echo "Saving files in working directory to the file savethem."
exec > savethem
for i in *
do
echo
"==================================================="
echo "File: $i"
echo
"==================================================="
cat "$i"
done
a. Which error message do you receive when you execute this script?
Rewrite the script so that the error does not occur, making sure the output
still goes to savethem.
b. What might be a problem with running this script twice in the same
directory? Discuss a solution to this problem.
a. You receive the following error message:
cat: savethem: input file is output file
To eliminate the error message, add the following lines after the line with
do on it:
if [ $i == "savethem" ] ; then
continue
fi
b. Each time you run savefiles, it overwrites the savethem file with the cur-
rent contents of the working directory. When you remove a file and run
savefiles again, that file will no longer be in savethem. If you want to keep
an archive of files in the working directory, you need to save the files to
a new file each time you run savefiles. If you prefix the filename savethem
with $$, you will have a unique filename each time you run savefiles.
You might also like to view...
Which of the following statements are true?
a. A PriorityQueue orders its elements according to their natural ordering using the Comparable interface if no Comparator is specified. b. A PriorityQueue orders its elements according to the Comparator if a Comparator is specified in the constructor. c. The priority of a PriorityQueue cannot be changed once a PriorityQueue is created. d. The priority of a PriorityQueue cannot be reversed once a PriorityQueue is created.
Choose font colors that contrast pictures inserted in a presentation
Indicate whether the statement is true or false
Pointing to a sizing handle of a chart allows you to move it. __________________________
Answer the following statement true (T) or false (F)
In the accompanying figure, you can ____ the item on which the mouse pointer is resting at the top or bottom of the screen or float it in any other location in the workspace.
a. grip
b. land
c. launch
d. dock