The following shell script adds entries to a file named journal-file in your home directory.  It can help you keep track of phone conversations and meetings.

$ cat journal
# journal: add journalentries to the file
# $HOME/journal-file

file=”$name” n >> $file
date >> $file
echo “Enter name of person or group: \c”
read name
echo “$name” >> $file
echo >> $file
cat >> $file
echo”------------------------------------------------------------------------------------------------“>> $file
echo >> $file

 Why does it use the read built-in the first time it accepts input from the terminal and the cat
utility the second time?
Who is Participating?

Because when you just tyype "at >> $file" it assumes the input will come from terminal (standard input as default)

read reads a single line
cat reads until end of file
Vinit KainCommented:
read name

takes the input whenever you press "enter"

cat >> $file

wait till Cntl+D

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.