zsh-users
 help / color / mirror / code / Atom feed
* create variable with calculated number of spaces.
@ 2024-05-06 22:03 Ray Andrews
  2024-05-06 22:33 ` Mark J. Reed
  0 siblings, 1 reply; 11+ messages in thread
From: Ray Andrews @ 2024-05-06 22:03 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 647 bytes --]

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.


[-- Attachment #2: Type: text/html, Size: 958 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-05-07 14:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 22:03 create variable with calculated number of spaces Ray Andrews
2024-05-06 22:33 ` Mark J. Reed
2024-05-06 22:35   ` Mark J. Reed
2024-05-06 22:38     ` Mark J. Reed
2024-05-06 23:02       ` Ray Andrews
2024-05-06 23:28         ` Mark J. Reed
2024-05-06 23:41           ` Ray Andrews
2024-05-06 23:57       ` Lawrence Velázquez
2024-05-07  5:14         ` Ray Andrews
2024-05-07  5:52           ` Roman Perepelitsa
2024-05-07 14:56             ` Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).