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

I want to parse a variable (in my case it's development kit version) to make it dot(.) free. If version='2.3.3', desired output is 233.

I tried as below, but it requires . to be replaced with another character giving me 2_3_3. It would have been fine if tr . '' would have worked.

  1 VERSION='2.3.3' 
  2 echo "2.3.3" | tr . _
share|improve this question
No, it doesn't require: echo "2.3.3" | tr -d .. – manatwork Dec 12 '13 at 14:59
@manatwork Great, that works. You can post it as answer. Thanks – Prayag Upd Dec 12 '13 at 15:04
Lot of good answers. But if I can second-guess the objective, be warned about 2.11.3 and 2.1.13... ;-) Consider adding padding zeroes to numbers. – Rmano Dec 12 '13 at 16:06
@Rmano You mean something like VERSION='2.30.3100'? No matter what just .'s are removed with all of the answers here. – Prayag Upd Dec 12 '13 at 16:13
@PrayagUpd --- I simply meant that if you will use the number after the conversion for comparisons (as to say if "is this version newer or the same") you should take care of cases like 2.11.3 and 2.1.13 --- they seems the same after dot removal, but clearly 2.11.3 is newer. Also, 2.11.3 is newer than 2.1.14, but comparing 2113 and 2114 will lead to the wrong answer. I remember a bug somewhere for this... – Rmano Dec 12 '13 at 16:19
up vote 33 down vote accepted

There is no need to execute an external program. bash's string manipulation can handle it (also available in ksh (where it comes from) and zsh):

echo "${VERSION//.}"

(In those shells' manuals you can find this in the parameter expansion section.)

share|improve this answer
For further detail, the syntax of the above answer is ${string//substring/replacement}, where apparently the lack of the final forward slash and replacement string are interpreted as delete. See here. – sherrellbc Jan 6 at 18:19
Right, man bash says it clearly in the Shell Parameter Expansion section: “${parameter/pattern/string} (…) If string is null, matches of pattern are deleted and the / following pattern may be omitted.” – manatwork Jan 6 at 18:49

By chronological order:


echo "$VERSION" | tr -d .
echo "$VERSION" | sed 's/\.//g'


echo $VERSION:as/.//

POSIX shells:

set -f
set -- $VERSION
echo "$*"


echo "${VERSION//.}"


echo $VERSION:gs/./
share|improve this answer

you should try with sed instead

sed 's/\.//g'

share|improve this answer

In addition to the successful answers already exists. Same thing can be achieved with tr, with the --delete option.

echo "2.3.3" | tr --delete .

Which will output: 233

share|improve this answer

Your Answer


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

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