1833051 Members
2446 Online
110049 Solutions
New Discussion

Script ?? on variables

 
SOLVED
Go to solution
MikeL_4
Super Advisor

Script ?? on variables


What can I use to drop a character out of a variable in a script ??

In the variable ther is a . and would like to drop the character out. i.e. "1.15" would end of being "115"

5 REPLIES 5
James R. Ferguson
Acclaimed Contributor
Solution

Re: Script ?? on variables

Hi:

# echo "1.15"|sed 's/\.//'

Regards!

...JRF...
S.K. Chan
Honored Contributor

Re: Script ?? on variables

You can use sed ..
sed 's/\.//'
ie replacing the "." with nothing.
Patrick Wallek
Honored Contributor

Re: Script ?? on variables

Here's a way using awk:

VAR=1.15
VAR1=$(echo $VAR | awk -F . '{print $1$2}')


I'm sure there's a way to do it using sed too, but I am not that familiar with sed.
Leif Halvarsson_2
Honored Contributor

Re: Script ?? on variables

Hi,
Or the most simple:
echo 1.15 |tr -d .
MikeL_4
Super Advisor

Re: Script ?? on variables

Thanks much...