Link to home
Start Free TrialLog in
Avatar of negahdar
negahdar

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of MikeOM_DBA
MikeOM_DBA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
read reads a single line
cat reads until end of file
read name

takes the input whenever you press "enter"

cat >> $file

wait till Cntl+D

Vinit