shanenin Posted April 26, 2005 Report Share Posted April 26, 2005 I think i have copied this script exactly as printed in my book, but it keeps failingshane@mainbox shane $ cat scripts/loop#!/bin/bashx=0while [ $x -lt 10 ]do echo $x x=`echo "$X + 1" | bc`doneshane@mainbox shane $ ./scripts/loop0(standard_in) 1: parse error./scripts/loop: line 3: [: -lt: unary operator expected Quote Link to post Share on other sites
jcl Posted April 26, 2005 Report Share Posted April 26, 2005 (edited) Typo. 'x' is capitalized on the sixth line. Edited April 26, 2005 by jcl Quote Link to post Share on other sites
shanenin Posted April 26, 2005 Author Report Share Posted April 26, 2005 thanks. I can see debugging programs being a huge undertaking. I have trouble finding them with just three lines of code Quote Link to post Share on other sites
jcl Posted April 26, 2005 Report Share Posted April 26, 2005 thanks. I can see debugging programs being a huge undertaking. I have trouble finding them with just three lines of code By the way, if your book doesn't mention it, that could be rewritten to use shell arithmetic expansion:#!/bin/bashx=0while [ $x -lt 10 ]do echo $x x=$(($x + 1))doneor even:#!/bin/bashx=0while [ $x -lt 10 ]do echo $((x++))doneNot that I recommend deviating from the book. Quote Link to post Share on other sites
iccaros Posted April 26, 2005 Report Share Posted April 26, 2005 what is -lt (is that like NE or !=)while [ $x -lt 10 ]Not that I recommend deviating from the book.an why should you suggest a better way.. thanks Quote Link to post Share on other sites
shanenin Posted April 26, 2005 Author Report Share Posted April 26, 2005 what is -lt (is that like NE or !=) it means "less then"were you asking that? Quote Link to post Share on other sites
iccaros Posted April 26, 2005 Report Share Posted April 26, 2005 (edited) yep..sorry with this font I thought it was (one)t and I could not figure out what that stood for.. bash is confusing to me that way.. im used to < or <= .. this lt or ne and so on alwyas cates me off guard. thanks.. Edited April 26, 2005 by iccaros Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.