Simple BASH script; understanding loops and case
I'm trying to acquaint myself with shell scripting by following this guide and am getting stuck testing out this script.
All I want it to do is have the script loop continuously, and when I type in a command and 2 optional arguments, it performs the task. Simple way of testing whether I've "got it" or not. Specific questions: Am I using the cut command properly? Is [ ] usable when trying to cut by blank spaces? Am I using case right? Is there a way I could have the loop exit if I press ctrl-c or something like that? Code:
while [ read line ] |
Well your script reads some input into a variable called line but the rest of the script doesn't do anything with the variable $line, it then starts to work with the variable $inputline. line is actually the name of a command so it's a poor choice of variable name.
With cut, I think the correct way of using a space as the field separator is with double quotes Code:
echo $inputline | cut -d " " -f 2 Code:
case $command in |
All times are GMT -5. The time now is 04:40 PM. |