Rewrite the journal script of Chapter 8 (exercise 5, page 3) by adding com- mands to verify that the user has write permission for a file named journal- file in the user’s home directory, if such a file exists. The script should take appropriate actions if journal-file exists and the user does not have write permission to the file. Verify that the modified script works.
What will be an ideal response?
$ cat journal2
# journal: add journal entries to the file
# $HOME/journal-file
file=$HOME/journal-file
# Check that $file is writable, exit if not
# (it is not writable if it does not exist)
if [ ! -w $file ]
then
echo "$file is not writable, it might not exist"
exit
fi
date >> $file
echo -n "Enter name of person or group: "
read name
echo "$name" >> $file
echo >> $file
cat >> $file
echo "--------------------------------------------------------"
>> $file
echo >> $file
You might also like to view...
A JavaFX action event handler contains a method ________.
a. public void actionPerformed(ActionEvent e) b. public void actionPerformed(Event e) c. public void handle(ActionEvent e) d. public void handle(Event e)
Assuming that list is a List
``` list.stream() .filter(value -> value % 2 != 0) .reduce(0, Integer::sum) ```