Home > Back-end >  How to remove the second dot in my string format using bash scripting? [duplicate]
How to remove the second dot in my string format using bash scripting? [duplicate]

Time:10-05

I am facing an issue on formatting strings.

So i have this variable that has this string value:
7.4.23

What I want to attain is to simply remove the extra trailing dot . so it would look like this: 7.4

CodePudding user response:

With bash and its Parameter Expansion:

version='7.4.23'
echo "${version%.*}"

Output:

7.4
  • Related