Hi All,
I am trying to create a script using
sed to search for a
. and
_ on a variable, and if it finds match, remove any value after a . or _.
For Example :
H.3 --> New Value should be
H
R2K_CL --> New value should be
R2K
Here's the command that I used:
#
echo $var | sed 's/[._].*$//'
But my problem is when the variable has several . or _
It should only remove the value after the last . or _.
For Example:
C4.1.2 --> New Value should be
C4.1
How will I update my
sed command to just remove the value after the last occurrence of a . or _?
Thanks,
racbern