Quick bourne scripting question

drag

Elite Member
Jul 4, 2002
8,708
0
0
I donno.

Maybe you misunderstood the task.
Maybe it was 'wait for user input then check to see the number of agruments', rather then check the actual user input you were waiting on.

Anyways, I think the trouble with your script there is that your using the string input rather then the variable input.
Try
for thing in $input


Also I think it's ((count++)) for doing that sort of thing, but I am not sure. don't do math in bash very much.

edit:
oh, and no spaces in the variable assignment.
count=0
not
count = 0
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Well sure.

It's obvious that his script was never intented to check the input of the user when replying. It only checks what they stuck on the command line.

So somebody is confused somewere. It's just as likely might be him. I don't know.

I've corrected teachers a few times..
 

Childs

Lifer
Jul 9, 2000
11,313
7
81
Your solution is correct, according to the original post. You could also simply do numbercount=`echo $numbers | wc -w` instead of the loop, but its all the same. It looks like your teacher combined two different tasks, argument parsing and user input.