shell

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?
negahdarAsked:
Who is Participating?
 
MikeOM_DBACommented:

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

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

takes the input whenever you press "enter"

cat >> $file

wait till Cntl+D

Vinit
0
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.