Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 08-08-2003, 06:10 PM   #1
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.


Old 08-10-2003, 05:07 PM   #2
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, 05:20 PM   #3
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"
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, 11:40 AM   #4
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.)



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 12:28 PM
Huge spaces in all variable width fonts Dare Linux - Software 0 10-21-2004 01:45 PM
Bash - Strip Spaces from string then cat cmfarley19 Programming 8 07-25-2004 01:01 PM
Removing spaces from string qcoder Programming 3 07-05-2004 01:35 PM
spaces in a string Longinus Programming 18 03-08-2004 07:02 PM

All times are GMT -5. The time now is 01:07 PM.

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