The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Replacing leading zeros with leading spaces deepakwins UNIX for Dummies Questions & Answers 5 06-18-2008 02:06 AM
remove leading spaces from a line lijojoseph Shell Programming and Scripting 6 03-17-2008 05:29 AM
Stripping leading spaces on right justified name Marcia P UNIX for Dummies Questions & Answers 2 02-28-2006 10:32 PM
Strip leading and trailing spaces only in a shell variable with embedded spaces jerardfjay Shell Programming and Scripting 6 03-07-2005 02:24 PM
Leading and Trailing Spaces sleepster Shell Programming and Scripting 7 10-29-2003 11:48 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-29-2008
grumm3t grumm3t is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 3
Leading spaces of variable removed

Code:
#!/bin/bash

TESTVAR="     5spaces"
echo $TESTVAR
Code:
hostame:~# ./test.sh
5spaces
The leading spaces from my variable are removed when the content is echo'd. I am trying to make some tabular data.

`echo -e` also fails.

Any suggestions?
  #2 (permalink)  
Old 08-29-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 741
Code:
echo "$TESTVAR"
...the variable put inside double-quotes will preserve spaces
  #3 (permalink)  
Old 08-29-2008
grumm3t grumm3t is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 3
Works great. Thanks!
Sponsored Links
Closed Thread

Bookmarks

Tags
preserve leading spaces

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0