I\'m looking to get 1.2.3.4 of string 1.2.3.4.5 I know that I can use this code to get the final number, but what can I use to get all numbers previous. (Including \':\')
Try using:
echo ${foo%.*}
Yielding:
foo="1.2.3.4.5" echo ${foo%.*} 1.2.3.4
and
foo="1 2 6" echo ${foo%.*}
yields
1 2 6
If you want to convert the spaces to ., you can use tr:
.
tr
echo $foo | tr ' ' '.'
Yielding the following for foo="1 2 6"
foo="1 2 6"
1.2.6