Results 1 to 2 of 2
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, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-16-2013 #1Just Joined!
- Join Date
- Jul 2012
- Posts
- 5
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" ]]
do
read line
line >> $f
echo "Added..."
count=$[$count +1]
done
echo "You have ""$count" "lines in the file."
exit
;;
[Nn]* )
echo "Ok. Goodbye."
rm "$f"
exit
;;
* )
echo "You must enter YES or NO!"
;;
esac
- 03-16-2013 #2Linux Newbie
- Join Date
- Nov 2012
- Posts
- 134
hi
what do you think `line >> $f` does ?
you need to read line before testing it against QUIT or quit.


Reply With Quote
