sed - regular expression
I need to extract substring :
my_string="foo bar(*.*)"; in variable1 should be "foo bar" in variable2 should be "*.*" So, everything text beetwen () should be in variable2. How to create sed regexp for it? |
Code:
variable1=$(echo $my_string | sed 's/\(.*\)(.*/\1/') |
Homework?
|
Quote:
|
Quote:
Code:
c="foo bar(*)" But if c="foo bar" [ Code:
@my myscript]$ ./script1.sh |
This should work:
Code:
e=$(echo $c | sed '/(/!d; /(/s/.*(\(.*\)).*/\1/') |
All times are GMT -5. The time now is 07:32 AM. |