LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-08-2003, 05:10 PM   #1
clsonnt
LQ Newbie
 
Registered: Jun 2003
Distribution: Redhat
Posts: 14

Rep: Reputation: 0
Question need to innitialize string variable with multiple spaces


I am working on a bash shellscript that needs to initialize a varible that contains multiple speces.

I have tried:
RDSK="c0t2d0s0 0"

What gets echo'd back is:
c0t3d0s0 0

If it matters, I am trying to edit the /etc/dumpdates file from my script.

TNX

Leon
 
Old 08-10-2003, 04:07 PM   #2
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Not sure what you are trying to do. It looks like the echo back is what I would expect. What are you are looking to be echoed back?
 
Old 08-10-2003, 04:20 PM   #3
slapNUT
Member
 
Registered: Jun 2001
Location: Recycle Bin
Distribution: Linux & Everything else on VirtualBox
Posts: 144

Rep: Reputation: 15
Just remember when you reference the variable you should quote it e.g.

$ RDSK="c0t2d0s0 0";[ "$RDSK" = "c0t2d0s0 0" ] && echo "YES";[ $RDSK = "c0t2d0s0 0" ] && echo "YES"
YES
bash: [: too many arguments
Notice the second test fails cause I use $RDSK without quotes and bash interprets both elements a arguements.
 
Old 08-11-2003, 10:40 AM   #4
clsonnt
LQ Newbie
 
Registered: Jun 2003
Distribution: Redhat
Posts: 14

Original Poster
Rep: Reputation: 0
Yea, Looks like that is the issue. I put the variable in Double quotes and it seems to work.

Now let's see about doing the actual editing from with in the script. (That will be a different post.)

Thanks!!!
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problems in removing white spaces from string of text monil Programming 7 03-08-2005 11:28 AM
Huge spaces in all variable width fonts Dare Linux - Software 0 10-21-2004 12:45 PM
Bash - Strip Spaces from string then cat cmfarley19 Programming 8 07-25-2004 12:01 PM
Removing spaces from string qcoder Programming 3 07-05-2004 12:35 PM
spaces in a string Longinus Programming 18 03-08-2004 06:02 PM


All times are GMT -5. The time now is 11:26 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