Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #204260

Re: Taming the "lsblk" command

From David Wright <deblis@lionunicorn.co.uk>
Newsgroups linux.debian.user
Subject Re: Taming the "lsblk" command
Date 2019-01-09 20:10 +0100
Message-ID <xeroJ-64W-5@gated-at.bofh.it> (permalink)
References (2 earlier) <xeh62-8bp-5@gated-at.bofh.it> <xelCG-2i4-15@gated-at.bofh.it> <xemyJ-2RP-7@gated-at.bofh.it> <xemS6-3e7-3@gated-at.bofh.it> <xeoKd-4p7-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed 09 Jan 2019 at 16:13:19 (+0000), mick crane wrote:
> On 2019-01-09 14:14, David Wright wrote:
> > On Wed 09 Jan 2019 at 13:54:45 (+0000), Curt wrote:
> > > On 2019-01-09, rhkramer@gmail.com <rhkramer@gmail.com> wrote:
> > > > On Wednesday, January 09, 2019 03:01:42 AM Richard Hector wrote:
> > > >> On 9/01/19 6:04 PM, Jude DaShiell wrote:
> > > >> > lsblk -l -o name,label | sort | script
> > > >>
> > > >> lsblk -ln -o name,label |sort | <script>
> > > >
> > > > I'm not the OP, but I very much like the way you put script in angle brackets
> > > > to show that is a parameter (mcow) and not a literal value!!
> > > 
> > > I'll see that affection for mundane angle brackets and raise you the
> > > annoyance of not having received the vaguest clue as to what might be
> > > found literally inside them (the pertinent part, at the very least).
> > 
> > I don't think the OP told us what the script was, but just that they
> > want to pipe the output into "a script". Using angle brackets from the
> > start (or knowing that script itself is a program) would have avoided
> > the mess in the other subthread.
> 
> /usr/bin/script looks like it might be handy sometime ( didn't know
> about that )
> there's a line in the answers to clean up the output.
> https://superuser.com/questions/236930/how-to-clean-up-output-of-linux-script-command

That perl script is useful, so it might be worth posting here:

perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' < typescript | col -b | less

I just ran a typescript of an expert Debian installation over ssh, and
I think that's the best representation of curses screens I've seen,
short of using cut and paste.

But returning to lsblk, I can't figure out why the OP's lsblk -l
appears in such an odd order. Does it differ from that given by
lsblk with no arguments?

I've checked the unsorted order of my /sys/dev/block, which is
essentially random, as is the order of block devices in the output
of mount, yet lsblk gives me a nice sorted lists:

$ lsblk -o name
NAME
sda
├─sda1
├─sda2
├─sda3
├─sda4
├─sda5
├─sda6
├─sda7
├─sda8
│ └─swanhome
├─sda9
├─sda10
├─sda11
├─sda12
├─sda13
└─sda14
sdb
└─sdb1
  └─luks-b1b5d363-c048-40e6-8030-fed7a20e37ab
sdc
  └─sdc1
$ lsblk -o name -l
NAME
sda
sda1
sda2
sda3
sda4
sda5
sda6
sda7
sda8
sda9
sda10
sda11
sda12
sda13
sda14
sdb
sdb1
sdc
sdc1
swanhome
luks-b1b5d363-c048-40e6-8030-fed7a20e37ab
$ 

The disadvantage (to me) with external sorting is that the order
becomes alphanumeric instead of numerical (though a script could
work around that by splitting the name field).

Cheers,
David.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Taming the "lsblk" command Richard Owlett <rowlett@cloud85.net> - 2019-01-08 22:00 +0100
  Re: Taming the "lsblk" command Reco <recoverym4n@enotuniq.net> - 2019-01-08 22:20 +0100
  Re: Taming the "lsblk" command Jude DaShiell <jdashiel@panix.com> - 2019-01-09 06:10 +0100
    Re: Taming the "lsblk" command Richard Owlett <rowlett@cloud85.net> - 2019-01-09 07:30 +0100
    Re: Taming the "lsblk" command Felix Miata <mrmazda@earthlink.net> - 2019-01-09 07:50 +0100
      Re: Taming the "lsblk" command Bob McGowan <ramjr0915@gmail.com> - 2019-01-09 08:00 +0100
      Re: Taming the "lsblk" command Jude DaShiell <jdashiel@panix.com> - 2019-01-09 12:50 +0100
        Re: Taming the "lsblk" command Felix Miata <mrmazda@earthlink.net> - 2019-01-09 14:00 +0100
          Re: Taming the "lsblk" command David Wright <deblis@lionunicorn.co.uk> - 2019-01-09 15:30 +0100
    Re: Taming the "lsblk" command Richard Hector <richard@walnut.gen.nz> - 2019-01-09 09:10 +0100
      Re: Taming the "lsblk" command rhkramer@gmail.com - 2019-01-09 14:00 +0100
        Re: Taming the "lsblk" command Curt <curty@free.fr> - 2019-01-09 15:00 +0100
          Re: Taming the "lsblk" command David Wright <deblis@lionunicorn.co.uk> - 2019-01-09 15:20 +0100
            Re: Taming the "lsblk" command Richard Owlett <rowlett@cloud85.net> - 2019-01-09 16:40 +0100
              Re: Taming the "lsblk" command Curt <curty@free.fr> - 2019-01-09 18:00 +0100
            Re: Taming the "lsblk" command mick crane <mick.crane@gmail.com> - 2019-01-09 17:20 +0100
              Re: Taming the "lsblk" command David Wright <deblis@lionunicorn.co.uk> - 2019-01-09 20:10 +0100
                Re: Taming the "lsblk" command Michael Stone <mstone@debian.org> - 2019-01-09 22:40 +0100
                Re: Taming the "lsblk" command David Wright <deblis@lionunicorn.co.uk> - 2019-01-10 02:00 +0100
                Re: Taming the "lsblk" command Michael Stone <mstone@debian.org> - 2019-01-10 13:50 +0100

csiph-web