I am trying unsuccessfully to set into a variable a specific part of command output:
The command output will be as:
line 1: <varied>
line 2: 2 options:
option 1:
Set view: ** NONE **
or
option 2:
Set view: <different_name_of_views_always_without_spaces>
and I would like to get into the variable either the ** NONE ** or the name of the view (<different_name_of_views_always_without_spaces> in option 2).
What is the syntax to find that "field" into my variable?
Thanks,
I tried the advised code as following:
echo "test123"
v1=`ct pwv | grep 'Set view: ** NONE **'`
echo $v1
and I get:
test123
(empty line after the test123)
Any idea?
In the 2nd option for the command output (Set view: <different_name_of_views_always_without_spaces>) the last part (<different_name_of_views_always_without_spaces>) is varied and may be any string, how can I catch that string?
For getting nothing as output I guess the grep'ed pattern is wrong then. Best try it without assigning it to a variable if grep finds something on the command line.
For the other pattern you want to find.. can we sum it up that you simply want any output that starts with "Set view:" ?
regarding the other pattern - What I want to be set into the variable is the next string without spaces (till next space or new line) right after "Set view: "
any suggestion?