Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a bash script which reboots the system at each reboot it adds a new line to a text file, I then read the text file before each reboot. Once the variable holding the number of lines reaches say 10 I want the script to delete the text file (at which point on the next reboot it will see the file isn't there, break the loop and prompt the user to start again). I've tried this:

exec < text.txt
while read line
nol=`expr $nol + 1`

if ["$nol" == "$reboot_count"];
rm text.txt

but this doesn't seem to be working, all help is appreciated :)

share|improve this question
up vote 3 down vote accepted

[ is a command (an alias for test, in fact). You should separate it by whitespace from the surrounding text.

share|improve this answer
oops :( only starting bash scripting today still a lot to learn, thank you! – twigg Sep 8 '12 at 1:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .