Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help /proggles/~

Name: Anonymous 2012-08-03 2:06

I'm currently working on a bash script and I want to define multiple variables the same way. All of them are defined the same, so it seems inefficient to define each one individually. Is there a way to define an entire array all at once, rather than each individual variable?

This is an extreme oversimplification, but I want to do something like this:

array=( $a $b $c)
array=1

And then all the variables would have a value of 1.

Here's something like what I'm currently doing:
a=1
b=1
c=1

It seems like such an inefficient way to do it though. So what should I do?

Thanks in advance for any and all help.

Name: Anonymous 2012-08-03 2:12

Actually, I found another solution, but it still involves multiple lines:

function asdf() {
[insert function for defining the variables here]
}
a=$(asdf)
b=$(asdf)
c=$(asdf)


It's an improvement, but it's still not ideal. Any thoughts on any other way to do it? Or should I not dwell on stuff like this?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List