The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 07-25-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Cool take a look at the following

Code:
> 
> fname="George              "
> lname="Washington          "
> full=$(echo $fname $lname)
> echo $full
George Washington
> echo "$full" "*"
George Washington *
> fullt=$(printf "%-50s" "$full")
> echo "$fullt" "*"
George Washington                                  *
>
I used the "*" to help see spacing on the screen.
The printf commands was the key.
Also be careful of use of " " around variables; using means extra space characters are kept while not using and the shell will truncate extra space characters.