LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 03: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, 09: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,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
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, 12:28 PM   #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, 02:18 PM   #4
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,169

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
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 10:09 PM
Special Characters SimeonV Suse/Novell 14 07-07-2006 02:29 PM
special characters greenbox Linux - Software 9 12-23-2005 08:33 PM
Special characters consty Programming 3 08-07-2005 06:53 AM
using special characters one_ro Mandriva 5 11-04-2004 09:52 AM


All times are GMT -5. The time now is 04:47 PM.

Main Menu
Advertisement
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