Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable formatting inquiry

Status
Not open for further replies.
Joined
Aug 3, 2001
Messages
29
Location
US
I am trying to build one variable from information gathered in a script.

example:

var1=abcdedfg
need to pad this to 15 characters

var2=file name
need to pad this to 256 characters

var3="set id" (3chars always)

var1 and var2 can change all the time

I want to be able to set up a variable

var4=var3+var1+var2 into one string


Thanks


Len
 
#!/bin/ksh
typeset -L15 var1
var1="abcdedfg"
echo "var1->[$var1]"
#need to pad this to 15 characters

typeset -L256 var2
var2="file name"
#need to pad this to 256 characters

var3="SID" # (3chars always)

#var1 and var2 can change all the time
#
#I want to be able to set up a variable
#
var4="${var3}${var1}${var2}" # into one string
echo "var4->[$var4]"
vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
vgersh99,

I keep getting the diplay with the &quot;[&quot; at each end.
Am I being to literate in following the setup of variables.
I want to be to utlize this information and put it in a work file as a variable.


Thanks for the quick response

Len
 
I've posted a sample code showing your the technique - you'll have adopt it to your use.

The '[]' are coming from the last &quot;echo&quot; statement showing you the result of using the 'technique'.
vlad
+---------------------------+
|#include<disclaimer.h> |
+---------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top