The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
please help me regarding alias naree Shell Programming and Scripting 17 06-03-2008 01:14 AM
Alias Help NetJones UNIX for Dummies Questions & Answers 1 03-16-2008 02:47 AM
Bourne: How to invoke an alias from within a shell script techshots Shell Programming and Scripting 2 06-03-2006 09:38 PM
Perl + pack() + spaceing question Optimus_P Shell Programming and Scripting 1 10-02-2002 07:03 AM
Alias JSP UNIX for Dummies Questions & Answers 2 09-29-2001 08:17 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-15-2002
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
spaceing in an shell alias

ok this is my problem.
I have a variable that is very specific in spaceing but when ever i try to use the variable i only get 1 empty space vs 3 for example.

Code:
$ list="list   me"
$ echo $list
list me
$ list2="one          two       three"
$ echo $list2
one two three
i have tried pretty much every variation of quotes and ticks. but its just not working.

Last edited by Optimus_P; 07-15-2002 at 09:25 AM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-15-2002
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
Put quotes around the variable when using it.
Code:
$ list="one   two"
$ echo $list
one two
$ echo "$list"
one   two

Last edited by Perderabo; 07-15-2002 at 10:09 AM.
Reply With Quote
  #3 (permalink)  
Old 07-15-2002
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
if you looked at my example i already tried that. also look at your example you will notice one 1 blank space. try that with 2 and it will not work.
Reply With Quote
  #4 (permalink)  
Old 07-15-2002
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
It has two (actually three) but did not post here correctly.

It did work using the quotes around the variable when doing the echo.

What shell are you using? I tried this in sh, ksh, and csh. All worked the same in the output (set list = instead of list= in csh).

Are you testing this from a prompt using the example given? What OS are you using (worked the same on Solaris and HP-UX for me)?

And if you look at your example, you didn't post that you tried this. You spoke of trying it on the variable assignment, not when reading the variable.
Reply With Quote
  #5 (permalink)  
Old 07-15-2002
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
i appoligize. i apparently misread ur post.

after i was digging thru my korn book on page 69 they gave an example of exactly what i was trying to do.

then i look up and see that you had replyed again to my post.

so thank you for the correct answer.

~Mike
Reply With Quote
  #6 (permalink)  
Old 07-15-2002
RTM's Avatar
RTM RTM is offline
Hog Hunter
 
Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
Never a problem - I still can't get the spaces in there (tried editing) - it just post funny on here -looks right when I'm doing it but comes out wrong (it is the same as your problem - it formats extra blank space out of there).
Reply With Quote
  #7 (permalink)  
Old 07-15-2002
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
use the \[code\] to get your spaceing correct.

then end it in \[/code\]
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0