Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

please advice how to remove only the second "." character from the version number with awk

I need to fit the syntax for Linux & Solaris

I write the

  sed "s'/\./ /g'" - 

but this syntax remove all "." from the version number

for example (version number before)

after sed manipulation will be

 34.34 55.4
share|improve this question
Have you considered awk instead? Doing this with SED is going to be painful simply because it has a very limited ability to deal with any kind of state. – Zoredache Feb 16 '12 at 7:52
@Zoredache although I usually recommend awk as well, its not so painful in sed ;) – SiegeX Feb 16 '12 at 7:53
ok I update the question – Eytan Feb 16 '12 at 7:57
up vote 3 down vote accepted
echo -e '\n2.3.4\n5.6.7.8' | sed 's/\([^.]*\.[^.]*\)\./\1 /'

The part in braces will match "something without dot, a dot, something without dot". \1 in the replacement text will then refer to this submatch.

However, the other solution given is arguably far more elegant ;-)

share|improve this answer
$ sed 's/\./ /2' <<<''
34.34 55.4
share|improve this answer
this syntax not work on solaris – Eytan Feb 16 '12 at 9:40
@Eytan the <<<'' part was just an example for input. Simply replace it with a file name, or pipe something to it with echo. The sed command will certainly work. – SiegeX Feb 16 '12 at 16:53

Using GNU Awk:


awk '$0 = gensub( /\./, " ", 2 )' <<<""


34.34 55.4
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .