I've got some command which output looks like that:
some_command Current view: username_token1_token2_token3_4_token4_2
How could I parse the "token3_4_token4_2" part out of the string?
Here it is in Perl:
Works as follows:
Initially the string
search and replace
Matches a string_ (i.e. part of the .... above)
Matches 3 of them
replaces them with nothing (i.e. deletes)
print what's left of $_
Just using bash:
I used a process substitution to redirect the output of the command into the read statement. If I were to have used a pipe, then the read would have occurred in a subshell and the $c variable would not have existed in the parent shell.