From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 241FB25098 for ; Tue, 7 May 2024 01:58:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Subject:To:From:Date: References:In-Reply-To:Message-Id:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=cD7MMG0gI6UtbD9d4xpXaNPQMWR+xeTsUR1CjMQ0wQE=; b=WQoaWPy1d4slijOHZQjSqdhgAR GeEs1pnwgHVPsuBzjlp9N1/1gETFOu5nChSEeQMqJiCQ2QQTpiu1BZvJHi7sRKSYZ+h1fQQHA6CLB 2x3clyiRMX6BQrtbMayDXt0k+WtMardogb154SvLRtsEtfZT5QXeQiU8wdPutnM3wIQBStp0hOZN8 5WmGH+H1qNz3zmu75XDaa8hsxU9RqJxDy1WmciAb4gIb3tHeR98sg8+hBEximMSG5Pd1XWyAoz8b1 5ryS9VGTfG51n5/XBBMtm4cu1YSFHe4BHvU3968xBbiz5vRaMy1P4CJcod3WgIcDS1eIKbcZVR41a 9qng3MRg==; Received: by zero.zsh.org with local id 1s48E1-000MSC-6T; Mon, 06 May 2024 23:58:29 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1s48DY-000LkE-B0; Mon, 06 May 2024 23:58:00 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfauth.nyi.internal (Postfix) with ESMTP id E2C971200066 for ; Mon, 6 May 2024 19:57:58 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Mon, 06 May 2024 19:57:58 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvjedgvdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsehttd ertderreejnecuhfhrohhmpefnrgifrhgvnhgtvgcugggvlhojiihquhgviicuoehlrghr rhihvhesiihshhdrohhrgheqnecuggftrfgrthhtvghrnhepieelveehfefghfffieehtd eigedvgfekffetjefgteeltdeivdeivdetueekgeeknecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhihvodhmvghsmhhtphgruhhthh hpvghrshhonhgrlhhithihqdduudehudekjeejtdegqdduudelvdejfeekhedqlhgrrhhr hihvpeepiihshhdrohhrghesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id B36EB31A0065; Mon, 6 May 2024 19:57:58 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-437-gcad818a2a-fm-20240502.001-gcad818a2 MIME-Version: 1.0 Message-Id: In-Reply-To: References: <8809e9e7-2389-4bb7-ba67-95222d302594@eastlink.ca> Date: Mon, 06 May 2024 19:57:38 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: zsh-users@zsh.org Subject: Re: create variable with calculated number of spaces. Content-Type: text/plain X-Seq: 29919 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Mon, May 6, 2024, at 6:38 PM, Mark J. Reed wrote: > or, more efficiently: > > printf -v spacer "%${diff}s" '' And if the spacing is just being added to the beginning or end of string1, then don't bother with the spacer variable: # Left-padded printf -v string1 '%*s' $#string2 $string1 # Right-padded printf -v string1 '%-*s' $#string2 $string1 -- vq