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

Re: the splits



On Wed, May 22, 2024 at 4:21 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> On 2024-05-21 18:48, Mark J. Reed wrote:
>
> > When I want to select columns I usually reach for awk:
> >
> >  sudo lsof $mountpoint | awk '{print $1, $NF}'
>
> One little thing, can I have the first and last columns, but with a
> tab between, or some other columnizer?

Tab instead of space:

  awk '{print $1 "\t" $NF}'

Left-justified first column:

  awk '{printf "%-16s\t%s\n", $1, $NF}'

Columnized output:

  awk '{print $1, $NF}' | column -t

`column -t` is easy to use and produces nicely aligned output. The
downside is that it buffers all input, so it's not always applicable.

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author