[plug] Simple bash scripting problem

Craig Ringer craig at postnewspapers.com.au
Mon Oct 10 18:21:55 WST 2005


Craig Ringer wrote:
> Timothy White wrote:
> 
>> Ok. So this should be easy. I don't want to write this script in perl,
>> I have most of it in bash already so I would like a nice simple
>> answer. (Google's not being my friend, probably cause I'm tired)

`info bash' is more often useful for such things in my experience. For 
example, I recently found the extremly useful substring operations:

$ A="nothing_12"
$ echo "Number is: ${A:8:2}"
12

Finding that the shell has built-in slicing etc makes it a much, much 
more attractive tool for scripting.

> [craig at albert ~]$ cat test.sh
> for item in "$@"; do
>         echo "Item is: $item"
> done
> [craig at albert ~]$ sh ./test.sh a b "cde" f
                                       ^^^
I swear that had spaces in it when I pasted it, really!
That syntax does work, though I

--
Craig Ringer



More information about the plug mailing list