LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 06-27-2012, 02:27 AM   #1
nano2
Member
 
Registered: May 2007
Posts: 100

Rep: Reputation: 15
assigning a value with special characters


Have the following scenario where by i have a mixture of integer values and special chars in a value and want to assign it to another value .

Code:
value1 = 3,6789

value2= $value1

expected  value2 = 3,6789

actual value2 '3 6789' is not a valid integer
using GNU bash, version 3.2.25

Any ideas how to solve this ?
 
Old 06-27-2012, 08:46 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
IDK where "actual value2 '3 6789' is not a valid integer" comes from ... ?

The bash assignment operator "=" must not have space either side of it so the code should be
Code:
value1=3,6789

value2=$value1
That will work but 3,6789 is not a valid integer; use 36789 instead.
 
Old 06-27-2012, 11:28 AM   #3
nano2
Member
 
Registered: May 2007
Posts: 100

Original Poster
Rep: Reputation: 15
I need the comma in it .
I have tried douuble quotes but then i get a comma replaced with a space

Any ideas to get this value2=3,6789
 
Old 06-27-2012, 01:18 PM   #4
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,771

Rep: Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272Reputation: 1272
I have tried and worked for me:
Code:
a=3,2345234
echo $a
3,2345234
b=$a
echo $b
3,2345234
just remove space before and after =
 
  


Reply

Tags
bash scripting


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] special characters help? bednarjm Fedora 8 06-18-2012 09:09 PM
Special Characters SimeonV Suse/Novell 14 07-07-2006 01:29 PM
special characters greenbox Linux - Software 9 12-23-2005 07:33 PM
Special characters consty Programming 3 08-07-2005 05:53 AM
using special characters one_ro Mandriva 5 11-04-2004 08:52 AM


All times are GMT -5. The time now is 09:30 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration