Posted on 2006-03-24
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?
Question by:negahdar
    LVL 29

    Accepted Solution


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

    LVL 84

    Expert Comment

    read reads a single line
    cat reads until end of file
    LVL 4

    Expert Comment

    by:Vinit Kain
    read name

    takes the input whenever you press "enter"

    cat >> $file

    wait till Cntl+D


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
    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.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now