I'd like to print only the part of a line enclosed
in parenthesis. For example:
input: junk_VAR1=12_junk_VAR2=231_junk
output: 12
In perl (this is too slow) it would be something like:
print ($line =~ /VAR1=(\d+)/);
Right now I'm substituting the entire line with \1, which
is faster than perl, but that can't be the most efficient
way to do it, can it?
echo $line | sed 's/^.*VAR1=\([0-9]*\).*$/\1/'
in parenthesis. For example:
input: junk_VAR1=12_junk_VAR2=231_junk
output: 12
In perl (this is too slow) it would be something like:
print ($line =~ /VAR1=(\d+)/);
Right now I'm substituting the entire line with \1, which
is faster than perl, but that can't be the most efficient
way to do it, can it?
echo $line | sed 's/^.*VAR1=\([0-9]*\).*$/\1/'