We help IT Professionals succeed at work.


negahdar asked
Medium Priority
Last Modified: 2013-12-26
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?
Watch Question

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Most Valuable Expert 2014
Top Expert 2015

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

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.