zsh-users
 help / color / mirror / code / Atom feed
From: Jim <linux.tech.guy@gmail.com>
To: Ray Andrews <rayandrews@eastlink.ca>
Cc: zsh-users@zsh.org
Subject: Re: the splits
Date: Wed, 22 May 2024 00:57:28 -0500	[thread overview]
Message-ID: <CA+rB6GJJWPqFv-qm5TCe2wiD5dba4Gj1h1D9=GW6N8-8y7C6Ow@mail.gmail.com> (raw)
In-Reply-To: <0b6a048b-4fbf-4162-a31a-d5f6f963d72a@eastlink.ca>

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

Ray,

On Tue, May 21, 2024 at 9:21 PM Ray Andrews <rayandrews@eastlink.ca> wrote:

>
> On 2024-05-21 18:48, Mark J. Reed wrote:
>
> Running *lsof* *| grep* seems a bit silly. Can't you just do *lsof
> $mountpoint*?
>
> When I want to select columns I usually reach for *awk*:
>
>  *sudo lsof $mountpoint | awk '{print $1, $NF}'*
>
>
> Beautiful, nuts' I just presumed I needed to grep for that. Much faster
> your way.  As for awk, I don't know anything about it, but googling for
> help on various issues, one sees awk coming to the rescue all the time.  I
> half way learned sed, but I think I should have learned awk. One little
> thing, can I have the first and last columns, but with a tab between, or
> some other columnizer?:
>
> COMMAND    NAME
> zsh        /mnt/sda/5/boot
> geany      /mnt/sda/5/boot
>

Maybe something like this would work for you.  Except for lsof it is all
shell code.

L=15  # insure first field reserves L columns (adjust as needed)
lsof $mountpoint | \
  while read -r line ; do
    print -- ${(r.L.. .)${=line}[1]} ${${=line}[-1]}
  done

Regards,

Jim Murphy

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

      parent reply	other threads:[~2024-05-22  5:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 17:42 Ray Andrews
2024-05-22  1:48 ` Mark J. Reed
2024-05-22  2:21   ` Ray Andrews
2024-05-22  5:56     ` Roman Perepelitsa
2024-05-22 19:25       ` Ray Andrews
2024-05-22 20:41         ` Lawrence Velázquez
2024-05-22 21:36           ` Ray Andrews
2024-05-23  0:04             ` Lawrence Velázquez
2024-05-23  0:30               ` Ray Andrews
2024-05-23  2:31                 ` Mark J. Reed
2024-05-23 12:58                   ` Ray Andrews
2024-05-22  5:57     ` Jim [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+rB6GJJWPqFv-qm5TCe2wiD5dba4Gj1h1D9=GW6N8-8y7C6Ow@mail.gmail.com' \
    --to=linux.tech.guy@gmail.com \
    --cc=linuxtechguy@gmail.com \
    --cc=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).