Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
create variable with calculated number of spaces.
- X-seq: zsh-users 29912
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: create variable with calculated number of spaces.
- Date: Mon, 6 May 2024 15:03:22 -0700
- Archived-at: <https://zsh.org/users/29912>
- List-id: <zsh-users.zsh.org>
So I want to adjust the length of string1.
I do this by inserting a spacer in string1 who's length is
calculated from the length of string2:
local diff spacer
(( diff = $#string2 - 76 ))
for (( dd=1; dd<diff; dd++ )); do spacer+=' '; done
... # spacer will be incorporated into string1, not shown.
It works fine, but I'll bet there's a less laborious way -- some
way of creating 'spacer' with 'diff' number of spaces without the
for loop. I could make 'spacer' too long and then cut it at an
index [diff], but I doubt that's as simple as it could be. I know
it's there, I just can't quite remember.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author