how to lead space in value


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to lead space in value
# 1  
Old 05-09-2010
how to lead space in value

How to lead space instead of ZERO in the output:

Here I am using below code:

Quote:
#!/bin/ksh
a=$1
typeset -Z5 a
echo $a
exit
Here,
Input a =123
Output shows a =00123 instead of I want to display a =[SPACE][SPACE]123. here [SPACE] = just one space

I tried
Quote:
typeset -L5 a
and
Quote:
typeset -R5 a
and those are not working. Help please!
# 2  
Old 05-09-2010
why don't you go for printf statement.. print variable in right justified manner..
for more info refer man page :-)
# 3  
Old 05-09-2010
Hi.

Typeset -L / -R works, but you have to quote the variable, otherwise the whitespace is removed:

Code:
$ typeset -R20 a=Hello
$ echo $a
Hello
$ echo "$a"
               Hello
$ typeset -L20 a=Hello
$ echo $a World 
Hello World
$ echo "$a"World
Hello               World

 
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Gentoo

Help & lead me to the end. VFS: readonly/fs couldn't mount.

In a case of root=/dev/ram0 real_root=/dev/sda2 No filesystem could mount root, tried: ext3 ext2... Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0) http://imageplay.net/img/tya22288136/IMG0204A.jpg (real_root - real panic) The case of omitting real_root and... (1 Reply)
Discussion started by: Xcislav
1 Replies

2. News, Links, Events and Announcements

Android Captures Smartphone Lead In U.S.

Reference (1 Reply)
Discussion started by: Neo
1 Replies
Login or Register to Ask a Question