Web lists-archives.com

Re: taming lsblk command




On Wed, Jan 09, 2019 at 10:31:46AM -0500, Jude DaShiell wrote:
> On Wed, 9 Jan 2019, Jochen Spieker wrote:
> 
> > Date: Wed, 9 Jan 2019 10:17:50
> > From: Jochen Spieker <ml@xxxxxxxxxxxxxxxx>
> > To: debian-user@xxxxxxxxxxxxxxxx
> > Subject: Re: taming lsblk command
> >
> > Jude DaShiell:
> > > what works over here:
> > > lsblk -n < /usr/bin/sort
> >
> > This command feeds the content of the file /usr/bin/sort into stdin of
> > lsblk. That does not make sense and I guess lsblk is just ignoring this
> > input.
> >
> > J.
> >
> Script started on Wed 09 Jan 2019 10:30:00 AM EST
> jude[~]$ lsblk -n < /usr/bin/sort
> sda      8:0    0 111.8G  0 disk
> ??????sda1   8:1    0 111.8G  0 part /
> ??????sda2   8:2    0  32.5M  0 part [SWAP]
> sdb      8:16   0  55.9G  0 disk
> ??????sdb1   8:17   0    55G  0 part
> sr0     11:0    1  1024M  0 rom
> jude[~]$ exit
> exit
> 
> Script done on Wed 09 Jan 2019 10:30:50 AM EST

Still, I agree with Jochen here.

Lsblk just ignores its standard input (lucky you! -- who knows what
lurking bugs this unexpected input might tickle!). Your command
would do just the same without the < /usr/bin/sort.

With

  lsblk -n < /usr/bin/sort

you are feeding the contents of the /usr/bin/sort binary program to
lsblk's standard input.

Rather do:

  lsblk <options> | /usr/bin/sort <options>

or, typically:

  lsblk <options> | sort <options>

since /usr/bin *is* in your PATH (is it not? Complain to your sysadmin)
or (attention, bashism ahead!):

  sort <(lsblk)

(whitespaces matter here!), which will only work if your shell is bash,
but is the next resemblance to your command line above I could come
up with.

Cheers
-- tomás

Attachment: signature.asc
Description: Digital signature