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...
Any ideas?
S
|
Wouldn't something like this work, too:
|
|||||||||||||
|
|
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. |
|||||
|
|
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! |
|||||
|
grepand what you expect in each variable? Do you want each variable to have the same contents? – Dennis Williamson Nov 4 '09 at 12:09result2=$result1. If you have a dollar sign on the LHS, that'll use indirection. – Dennis Williamson Nov 4 '09 at 12:34