I what to have bash script to grep output to multiple variables but have no idea how to do that:
command |grep bla > $result1 $result2 etc...
You need to expand on what you're trying to do.
For instance, are you trying to parse random output where you want every line that happens after a line that has the word snoopy in it?
Such a thing could be accomplished by read and case in such a way:
If you want something else, let us know!
It would help if you gave some examples, but I think you might want something like:
You could then do multiple lines like the
But really, something that supports capturing groups with the regex is better than grep I think, I would use perl.
Or, if you want each line in a variable, you probably want an array. For example:
If you just want 'multiple assignment', the shell doesn't directly support that as far as I know. So you would:
If you need to do that for more than couple variables, you are probably not approacing the problem correctly, as always, best to state your end goal.
Wouldn't something like this work, too: