Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

create variable with calculated number of spaces.



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