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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing variabels in columes(like a left tap position.)

Status
Not open for further replies.

Larshg

Programmer
Mar 1, 2001
187
DK
Hi

I want to print a number of variabels at a specifik place on a line.

ex.
a=100
b=30
c=20

a shoule start at byte position 0
b should start at byte position 10
c should start at byte position 20

output
100 30 20

ex2.
a=1000
b=30000
c=200000

the same rules

output
1000 30000 2000000

Thanks

Lars
 
# a=100
# b=30
# c=20
# printf "%-20s%-20s%-20s\n" $a $b $c
100 30 20


PM
 
THe problem whit this is that if $b is empty, I still want $c to be printet at position 20

ex.
a=100
b=30
c=20
output
100 30 20

a=100
b=
c=20
output
100 20



 
Use quotes

printf "%-10s%-10s%-10s\n" "$a" "$b" "$c"
 
Try something like this:[/code]
printf "%-10s%-10s%-10s\n" "$a" "$b" "$c"[/code]


Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top