Results 1 to 3 of 3
I am pretty new to bash scripting so bare with me...
I am trying to write a script that will take an input and read it word for word and ...
- 05-04-2010 #1Just Joined!
- Join Date
- May 2010
- Location
- United States
- Posts
- 2
bash read input word for word
I am pretty new to bash scripting so bare with me...
I am trying to write a script that will take an input and read it word for word and then DO something with it like echo. I have been able to find how to read word for word from a file but I don't know how to do it with input.
I was looking for something like
The input would be A-Z a-z 0-9 and have a single space between each word. Any help or direction would be Much appreciated.Code:#!/bin/bash INPUT="${1}" for WORD in ${INPUT} do echo $WORD done exit 0
- 05-04-2010 #2Linux User
- Join Date
- Nov 2009
- Location
- France
- Posts
- 292
You have not specified about what you need help. Your script sounds error free. You just have to enclose your single argument in quotes :
Code:your_script.sh "orange and green"
0 + 1 = 1 != 2 <> 3 != 4 ...
Until the camel can pass though the eye of the needle.
- 05-04-2010 #3Just Joined!
- Join Date
- May 2010
- Location
- United States
- Posts
- 2
Argh... I had mistyped something in the script and managed to fix it when I typed the code in my forum post.
Thanks for pointing that out and I will make sure to explain my problem and the error better next time.
Thanks!


Reply With Quote