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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE, 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 0A2D8201B0 for ; Tue, 7 May 2024 07:16:06 +0200 (CEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1715058966; b=cdp8gThqOprOYV8mSmJ0EWMVP0kY1XQcxCXmI6Nuf8VdYCh06dJ7jbYaNdtzEgn0J38yeTBEPU N3/KV8sKtGyzWvKiqhm9bMb+euU13yn2RIfEEUNUQQiSzT2u/JsTt8+jazGKDPmNPDbeUnN82j 8ackYzl5OrVTT/3hX50EP7kz8e1Mui/jrKtAqSr8dj+38erR6mgB5MIU5hP8ycmujz4qpa4Pxp 8l0ehocH0ocQi8+nFDtWuo1pt/RtEpn27peCobE/WxfxWnlMC1OqKpuNVFqF3SmyVpl9kIHQQF 9JDJ6i7VwixGi5L6DIZteg5n24W/vz4NPyQYGvVdIdMcaw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1715058966; bh=VfOVuEXu/A6Ey620FzrxX8UiV82tQtd6Q6vL9ink+Hc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:From:References:To:Subject:MIME-Version:Date: Message-ID:Content-Type:DKIM-Signature; b=l5LoFL9z2t9lYrvZPwoQcSVgpfJxrXrstRwXY/bpOnt7KAXD5o4xrS1pc0Pybbdf4endT3mbNw 1b9JzOIgRIuYSanMU+OvrCGKLOp99ZgZgW/mH53q8mOo156BLUsf8UGeWkqI6qCkR0xURNRUN9 fg8ZuKkVftT5NZ9PtKMTgC8AiJ36Mhc8cNjorQmEGG765UthdEjL1DDlQS2Uer2+CkE1ADLfPt UqRvn3anKx4jrkHqepbnuTB4EgAuykmGC16Ix5wOHTyvnBzWdHQ3usvS1Vag60GsZHQ/pSpEOG AM5lmQpfJIBUA4WlbnKAMR6MKKl9OnGlfoibUj/s2ew+Rw==; 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:In-reply-to:From:References:To: Subject:MIME-version:Date:Message-id:Content-type:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ZRzjZaqjKvFEoQvNyTnaDidrHMi6yRrViaJfiaYQZ5Y=; b=oOSlF7lDKPODoBFg+Hix97cnWG adK5MSc5mX9EygTdVWPO17tNABWBjaEuB8UuLYQWOh1/ckZ5FQvnsPLhY0wUSkRyyLudjIjTv9i60 zLRsQRRKWWlh7GrPFM/gKSZhHIlU6ZYpFZqLzGHTiwfYxJP2wVQxdcMW18iohTS2gtyJmAiqvE0d+ 0k0d4wV83t3oHzs6MB1AfdtpDKRyrb3+/N1tSJfHBKAod+omJHK/9c4pGIRq0+N1ELstsE4nAZBlB XEFh2yOhrywXYftP2NNz8fmIHPGlnRaU1FNhEtPt7yLIVkkqplrjJPNm6RtDJIal+0Un2jwAMDdEi LsTQLWHw==; Received: by zero.zsh.org with local id 1s4DBO-0006JS-BT; Tue, 07 May 2024 05:16:06 +0000 Authentication-Results: zsh.org; iprev=pass (mta03.eastlink.ca) smtp.remote-ip=24.224.136.9; dmarc=none header.from=eastlink.ca; arc=none Received: from mta03.eastlink.ca ([24.224.136.9]:47589) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1s4D9z-0005Uj-Nu; Tue, 07 May 2024 05:14:40 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta03.eastlink.ca ([24.224.136.9]) with ESMTPS id <0SD30W9DXNWDCHH1@mta03.eastlink.ca> for zsh-users@zsh.org; Tue, 07 May 2024 02:14:38 -0300 (ADT) Received: from [192.168.0.11] (host-24-207-19-13.public.eastlink.ca [24.207.19.13]) by csp01.eastlink.ca ([71.7.199.166]) with ESMTPSA id 4D9xsrvH198ni4D9yspa8C (version=TLSv1_2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256); Tue, 07 May 2024 02:14:38 -0300 X-Authority-Analysis: v=2.4 cv=C75KyhP+ c=1 sm=1 tr=0 ts=6639b8be a=e7T7DzMKK1R988ZCg0wLyw==:117 a=e7T7DzMKK1R988ZCg0wLyw==:17 a=r77TgQKjGQsHNAKrUKIA:9 a=HQnowA5Efc4mGxpJG9wA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=ZLGELXoPAAAA:8 a=gCOqIVrS4xCAHeBXMDIA:9 a=m2fxqKhfqIzavZBR:21 a=_W_S_7VecoQA:10 a=CFiPc5v16LZhaT-MVE1c:22 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvddvjedgkeekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecugfetuffvnffkpffmpdfqfgfvnecuuegrihhlohhuthemuceftddtnecunecujfgurheptgfkffggfgfuvfhfhfgjsegrtderredtvdejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpefhteethfevgeeuvdelgefgvdevudefueduffdvgfelvddvgfdtieegueeuleeifeenucfkphepvdegrddvtdejrdduledrudefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdegrddvtdejrdduledrudefpdhhvghloheplgduledvrdduieekrddtrdduudgnpdhmrghilhhfrhhomheprhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrpdhnsggprhgtphhtthhopedvpdhrtghpthhtohepreerpdhrtghpthhtohepiihshhdquhhsvghrshesiihshhdrohhrghdpghgvthdqkghiphfrrghsshifugepthhruhgv X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Content-type: multipart/alternative; boundary="------------8Z0jR0RDZRXeYyKn5b1HZclq" Message-id: <2c187631-8284-4f35-a1a2-f982e42dd704@eastlink.ca> Date: Mon, 6 May 2024 22:14:36 -0700 MIME-version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: create variable with calculated number of spaces. To: zsh-users@zsh.org References: <8809e9e7-2389-4bb7-ba67-95222d302594@eastlink.ca> Content-language: en-US From: Ray Andrews In-reply-to: X-Seq: 29920 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: This is a multi-part message in MIME format. --------------8Z0jR0RDZRXeYyKn5b1HZclq Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024-05-06 16:57, Lawrence Velázquez wrote: > 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 Gotta start using printf to cobble together complicated variables. But in this case it's internal: % mnt Label:     Partition:    Mountpoint:  Size:    Free:    Used: %Used: b6-12-Deb12b     sda6    /            11.7G     5.6G     5.5G 47% b3--0-aWorking   sda3    /aWorking   280.5M   157.2M   104.3M 37% b2--0-boot       sda2    /boot       188.2M   131.2M    43.0M 23% b8--6-root1      sda8    /root         5.8G     2.4G     3.1G 53% b11---aRay       sda11   /aRay        15.6G     6.2G     8.5G 55% b10-5-aMisc      sda10   /aMisc        4.8G     4.5G   121.1M 2% % mnt sda Label:     Partition:    Mountpoint:     Size:    Free:    Used: %Used: b6-12-Deb12b     sda6    /               11.7G     5.6G 5.5G    47% b3--0-aWorking   sda3    /aWorking      280.5M   157.2M 104.3M    37% b2--0-boot       sda2    /boot          188.2M   131.2M 43.0M    23% b8--6-root1      sda8    /root            5.8G     2.4G 3.1G    53% b11---aRay       sda11   /aRay           15.6G     6.2G 8.5G    55% b10-5-aMisc      sda10   /aMisc           4.8G     4.5G 121.1M     2% b5-12-Deb11a     sda5    /media/sda/5    11.7G     4.2G 6.8G    58% b7-12-Deb12c     sda7    /media/sda/7    11.7G     5.6G 5.5G    47% b9--6-root2      sda9    /media/sda/9     5.8G     2.4G 3.1G    53% ... 'findmnt' outputs nice columns so the thing is to space the 'title' line accordingly -- it's mostly the mountpoint who's width can vary so the spacer goes in there.  Purely cosmetic. --------------8Z0jR0RDZRXeYyKn5b1HZclq Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

On 2024-05-06 16:57, Lawrence Velázquez wrote:
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
Gotta start using printf to cobble together complicated variables.  But in this case it's internal:

% mnt

Label:     Partition:    Mountpoint:  Size:    Free:    Used:  %Used:

b6-12-Deb12b     sda6    /            11.7G     5.6G     5.5G    47%
b3--0-aWorking   sda3    /aWorking   280.5M   157.2M   104.3M    37%
b2--0-boot       sda2    /boot       188.2M   131.2M    43.0M    23%
b8--6-root1      sda8    /root         5.8G     2.4G     3.1G    53%
b11---aRay       sda11   /aRay        15.6G     6.2G     8.5G    55%
b10-5-aMisc      sda10   /aMisc        4.8G     4.5G   121.1M     2%

% mnt sda

Label:     Partition:    Mountpoint:     Size:    Free:    Used:  %Used:

b6-12-Deb12b     sda6    /               11.7G     5.6G     5.5G    47%
b3--0-aWorking   sda3    /aWorking      280.5M   157.2M   104.3M    37%
b2--0-boot       sda2    /boot          188.2M   131.2M    43.0M    23%
b8--6-root1      sda8    /root            5.8G     2.4G     3.1G    53%
b11---aRay       sda11   /aRay           15.6G     6.2G     8.5G    55%
b10-5-aMisc      sda10   /aMisc           4.8G     4.5G   121.1M     2%
b5-12-Deb11a     sda5    /media/sda/5    11.7G     4.2G     6.8G    58%
b7-12-Deb12c     sda7    /media/sda/7    11.7G     5.6G     5.5G    47%
b9--6-root2      sda9    /media/sda/9     5.8G     2.4G     3.1G    53%

... 'findmnt' outputs nice columns so the thing is to space the 'title' line accordingly -- it's mostly the mountpoint who's width can vary so the spacer goes in there.  Purely cosmetic.





    

--------------8Z0jR0RDZRXeYyKn5b1HZclq--