/test4 Rich 140 3
Hello Rich,
The answer to your problem is 420
rich@testing:~>
Sometimes, though, instead of making your users supply information up front in the
command line, you need to ask questions on the fly. This can be done using the read
command:
#!/bin/bash
# asking for user input within the script
echo Please enter your name:
read name
echo ???Welcome, $name, pleased to meet you!???
Note that the variable is used without the dollar sign in the read command. When the
value is referenced in the echo command, you must use the dollar sign. When the read
command is processed, the script halts and waits for an entry from the user:
rich@testing:~> ./test5
Please enter your name:
Ima Test
Welcome, Ima Test, pleased to meet you!
Notice that the text input was a string with a space. The read command accepts all text
entered on the input line.
Flow Control
In a shell script, commands are executed in the order they appear in the text file. In many
programming situations though, you need to alter the program execution flow. This is
where the flow control commands come in handy.
Pages:
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374