Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
replacing dot in string, but leaving last one

replace the "." [dots], but leave the last one: e.g.: .txt [there could be random number of dots in the string, even zero, i just need the last one]

$ echo '' | SOMEMAGIC

share|improve this question

migrated from Jan 17 '11 at 19:38

This question came from our site for system and network administrators.

marked as duplicate by DMA57361, Benjamin Bannier, Nifle, BloodPhilia, grawity Jan 17 '11 at 21:57

This question was marked as an exact duplicate of an existing question.

Cross-posted on SuperUser:… – Bobby Jan 17 '11 at 16:01
$ file=''
$ ext=${file##*.}
$ base=${file%.$ext}
$ echo $base
$ temp=${base//./-}
$ echo $temp
$ newfile=${temp}.${ext}
$ echo $newfile
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.