However it may be impossible, I hope I'm just bad man reader =)
Is there any way to substitute text in variables on several patterns at time or even using back reference?
For example, I have FILE=filename.ext and I want to change it to filename_sometext.ext. But I don't know that file extension is .ext. All I know about it is that extension is after last dot.
So I can do it in two steps:
EXT=${FILE##*.}
FILE=${FILE%.*}_sometext.$EXT
Can I do it on one step (smth like ${FILE/.\(*\)/_sometext.\1} [that doesn't work])?
By the way I need to do it in pure shell without sed/awk/etc. My shell is ksh, but if there is way to do it with bashisms I'd like to know it too.
ksh88notksh93? – Mikel May 11 '12 at 8:55ksh88is what most people mean when they sayksh, and it doesn't support many features that are specific toksh93. Hence why I asked. ;-) – Mikel May 11 '12 at 15:20