Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

How to remove the first dot before the first number?

For example

I have the following file

  more file

  Version …………2.465.76.8.332

I want to get only the version number - 2.465768.332

share|improve this question
Your question title says delete first dot but sample output shows something else. Could you fix your question? – devnull Mar 18 '14 at 11:36
Also, what I never noticed, why do you remove the second and third dots from the version number? Is this a typo? – Graeme Mar 18 '14 at 11:43
Can we get confirmation on this Q whether we actually want to delete the leading dots or both the leading dots plus the 2nd and 3rd dots as well? – slm Mar 18 '14 at 15:50
up vote 2 down vote accepted

Assuming removing the dots from the version number is a typo.

sed can easily do the job:

echo 'Version …………2.465.76.8.332' | sed 's/^[^0-9]*//'

To extract only the version number from a file the number on is the first line beginning with 'Version' and nothing follows the version number, you could do:

sed -n '0,/^Version/ s/^Version[^0-9]*//p' file
share|improve this answer

Using sed you could say:

sed -n '/Version/{s/^[^0-9]*//;s/\([^.]*\.[^.]*\)\./\1/p}' filename

For your sample input, it'd produce:


As mentioned in the comment, it isn't quite clear what is the desired output. If it's the expected output as mentioned in the question body, you might use awk in order to improve readability:

sed -n '/Version/{s/^[^0-9]*//p}' inputfile | awk -F. '{print $1,$2$3$4,$5}' OFS=.

which would produce:

share|improve this answer
This will also process the numbers from any other line in the file that happens to contain the string 'Version' – Graeme Mar 18 '14 at 11:57
grep -oP 'Version.*?\K[\d.]+$' filename
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.