I have a String like this
this_is_test_string1_22
this_is_also_test_string12_6
I wanted to split and extracts string around the last underscore. That is i wanted the outputs like this
this_is_test_string1 and 22
this_is_also_test_string12 and 6
Can anyone help me how to get this in unix shell scripting.
Thanks. Sree
You can do
In BASH:
OR using sed:
EDIT for sh:
So puting ideas from anubhava and glenn... Full Shell script can be... as follwoing. you can choose to output to a file or display on the commandline...
Using
awk
: