Grep in a variable
Posted
by
Ashfame
on Ask Ubuntu
See other posts from Ask Ubuntu
or by Ashfame
Published on 2011-02-10T14:38:03Z
Indexed on
2011/02/10
15:33 UTC
Read the original article
Hit count: 265
grep
How to do a grep in a variable? I have stored the wget output in a variable and I need to extract out some strings from it.
Like the content of the variable is upgrade http://wordpress.org/download/ http://wordpress.org/wordpress-3.0.5.zip 3.0.5 en_US 4.3 4.1.2
I need to check if the string contains the word upgrade, so I can do a simple grep and then check the exit status of it by $?
and proceed. But how can I get the value 3.0.5
which is actually the fourth word? And how to actually grep in a variable?
© Ask Ubuntu or respective owner