Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    redirecting input to a file -- not exiting when "null" entered

    Hello all. I'm having trouble with this program used to delete and rebuild files. I need to stop inputting into the file when the null "quit" is entered. Also my, "Added...." , only displays every other input. I'm guessing my counter is only adding every other input also.
    Here's the section...

    echo -n "Would you like to rebuild file?"
    read reply

    case "$reply" in
    [Yy]* )
    echo "Start inputing information..."
    while [[ "$line" != "QUIT" || "$line" != "quit" ]]
    read line
    line >> $f
    echo "Added..."
    count=$[$count +1]
    echo "You have ""$count" "lines in the file."
    [Nn]* )
    echo "Ok. Goodbye."
    rm "$f"
    * )
    echo "You must enter YES or NO!"



  2. #2

    what do you think `line >> $f` does ?

    you need to read line before testing it against QUIT or quit.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts