I have a string like this:
data-c(huk24-small1);divider-bin-1.4.4;divider-conf-1.3.3-w(1,16);storage-bin-1.5.4;storage-conf-1.5.0-w(1);worker-bin-4.5.1;worker-conf-4.4.1-c(huk24)_20130620200658
where the timestamp with 14 digits and the underscore should be removed. So it should look like this:
data-c(huk24-small1);divider-bin-1.4.4;divider-conf-1.3.3-w(1,16);storage-bin-1.5.4;storage-conf-1.5.0-w(1);worker-bin-4.5.1;worker-conf-4.4.1-c(huk24)
How can I achieve this in a bash script? Note that removing should only happen, when there really is an underscore and 14 digits.
Use parameter expansion:
string=${string%_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With