How can I echo " " depend on variable?
I'm using bash and I wanted to know how can I echo " " depend on variable?
For example: Quote:
Result will be depend on $space Quote:
|
That could be done like this:
Code:
space=" " |
Code:
space="$space " Edit: Why does this butcher my caps ? i want to use all caps for shell variables, forum |
Quote:
Code:
SPACE="SPACE " Code:
[noparse]CAPS[/noparse] Code:
[code]CAPS[/code] and after several previews, it seems to work? More Coffee! |
@Habitual
i don't remember the forum doing this before maybe its just me remembering wrong edit: now it didn't convert them in CODE tags, or this line im confused anyway @OP Code:
#!/bin/bash |
Or, just set Space to the longest string of spaces you expect to need, and then echo an appropriate substring:
Code:
Space=" " |
Thanks :)
|
I don't really get your question, but perhaps it is about padding. Use printf:
Code:
$ printf '[%*s]\n[%-*s]\n' 12 "kuku" 12 "kuku" |
All times are GMT -5. The time now is 04:01 PM. |