?
Solved

shell

Posted on 2006-03-24
3
Medium Priority
?
1,187 Views
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?
0
Comment
Question by:negahdar
3 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 1500 total points
ID: 16282914

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

0
 
LVL 85

Expert Comment

by:ozo
ID: 16282931
read reads a single line
cat reads until end of file
0
 
LVL 4

Expert Comment

by:Vinit Kain
ID: 16371452
read name

takes the input whenever you press "enter"

cat >> $file

wait till Cntl+D

Vinit
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Loops Section Overview
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question