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


Groups > linux.debian.user > #256611 > unrolled thread

Is perl still the No.1 language for sysadmin?

Started bycoreyh@free.fr
First post2023-04-02 11:00 +0200
Last post2023-04-03 19:50 +0200
Articles 20 on this page of 133 — 33 participants

Back to article view | Back to linux.debian.user


Contents

  Is perl still the No.1 language for sysadmin? coreyh@free.fr - 2023-04-02 11:00 +0200
    Re: Is perl still the No.1 language for sysadmin? <tomas@tuxteam.de> - 2023-04-02 11:10 +0200
    Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 11:30 +0200
      Re: Is perl still the No.1 language for sysadmin? Jude DaShiell <jdashiel@panix.com> - 2023-04-02 11:50 +0200
      Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 00:20 +0200
      Re: Is perl still the No.1 language for sysadmin? Steve Sobol <steve@LobosStudios.com> - 2023-04-03 00:20 +0200
    Re: Is perl still the No.1 language for sysadmin? Nicholas Geovanis <nickgeovanis@gmail.com> - 2023-04-02 18:40 +0200
      Re: Is perl still the No.1 language for sysadmin? <tomas@tuxteam.de> - 2023-04-02 18:40 +0200
        Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 19:20 +0200
          Re: Is perl still the No.1 language for sysadmin? <tomas@tuxteam.de> - 2023-04-02 20:50 +0200
            Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 21:00 +0200
              Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 21:20 +0200
                Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 21:30 +0200
                Re: Is perl still the No.1 language for sysadmin? debian-user@howorth.org.uk - 2023-04-03 00:00 +0200
                  Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 00:10 +0200
                  Re: Is perl still the No.1 language for sysadmin? Steve Sobol <steve@LobosStudios.com> - 2023-04-03 01:10 +0200
                  Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 04:30 +0200
                    Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 05:50 +0200
                      Re: Is perl still the No.1 language for sysadmin? <tomas@tuxteam.de> - 2023-04-03 06:50 +0200
                    Re: Is perl still the No.1 language for sysadmin? <tomas@tuxteam.de> - 2023-04-03 06:50 +0200
                Re: Is perl still the No.1 language for sysadmin? <tomas@tuxteam.de> - 2023-04-03 06:40 +0200
                  Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 11:30 +0200
                  Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 15:00 +0200
              Re: Is perl still the No.1 language for sysadmin? Greg Wooledge <greg@wooledge.org> - 2023-04-02 21:20 +0200
                Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 02:00 +0200
                  Re: Is perl still the No.1 language for sysadmin? Ken Young <ken@highwinds.cloud> - 2023-04-03 02:30 +0200
          Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 01:40 +0200
      Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 19:20 +0200
        Re: Is perl still the No.1 language for sysadmin? debian-user@howorth.org.uk - 2023-04-02 22:10 +0200
          Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 22:40 +0200
            Re: Is perl still the No.1 language for sysadmin? Charles Curley <charlescurley@charlescurley.com> - 2023-04-02 23:20 +0200
          Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 22:50 +0200
        Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 01:20 +0200
      Re: Is perl still the No.1 language for sysadmin? Michel Verdier <mv524@free.fr> - 2023-04-02 22:50 +0200
        Re: Is perl still the No.1 language for sysadmin? Tom Browder <tom.browder@gmail.com> - 2023-04-02 23:10 +0200
          Re: Is perl still the No.1 language for sysadmin? coreyh@free.fr - 2023-04-03 06:30 +0200
            Re: Is perl still the No.1 language for sysadmin? Andy Smith <andy@strugglers.net> - 2023-04-03 06:50 +0200
              Re: Is perl still the No.1 language for sysadmin? coreyh@free.fr - 2023-04-03 07:00 +0200
            Re: Is perl still the No.1 language for sysadmin? Stanislav Vlasov <stanislav.v.v@gmail.com> - 2023-04-03 08:50 +0200
              Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 09:30 +0200
                Re: Is perl still the No.1 language for sysadmin? Michel Verdier <mv524@free.fr> - 2023-04-03 10:40 +0200
                Re: Is perl still the No.1 language for sysadmin? Stanislav Vlasov <stanislav.v.v@gmail.com> - 2023-04-03 11:20 +0200
                  Re: Is perl still the No.1 language for sysadmin? Michel Verdier <mv524@free.fr> - 2023-04-03 13:00 +0200
              Re: Is perl still the No.1 language for sysadmin? Vincent Lefevre <vincent@vinc17.net> - 2023-04-03 15:40 +0200
                Re: Is perl still the No.1 language for sysadmin? Stanislav Vlasov <stanislav.v.v@gmail.com> - 2023-04-03 18:50 +0200
        Re: Is perl still the No.1 language for sysadmin? Oliver Schoede <oliver.schode@online.de> - 2023-04-02 23:40 +0200
          Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 00:10 +0200
          Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 03:30 +0200
          Re: Is perl still the No.1 language for sysadmin? Andy Smith <andy@strugglers.net> - 2023-04-03 05:00 +0200
            Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 05:50 +0200
              Re: Is perl still the No.1 language for sysadmin? Andy Smith <andy@strugglers.net> - 2023-04-03 06:20 +0200
                Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-04 02:20 +0200
                  Re: Is perl still the No.1 language for sysadmin? local10 <local10@tutanota.com> - 2023-04-04 05:40 +0200
                    Re: Is perl still the No.1 language for sysadmin? Andy Smith <andy@strugglers.net> - 2023-04-04 15:50 +0200
                      Re: Is perl still the No.1 language for sysadmin? local10 <local10@tutanota.com> - 2023-04-05 00:50 +0200
        Re: Is perl still the No.1 language for sysadmin? Jude DaShiell <jdashiel@panix.com> - 2023-04-03 00:10 +0200
          Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 00:20 +0200
      Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 01:20 +0200
        Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 02:20 +0200
          Re: Is perl still the No.1 language for sysadmin? Eduard Bloch <edi@gmx.de> - 2023-04-03 23:30 +0200
            Re: Is perl still the No.1 language for sysadmin? Joel Roth <joelz@pobox.com> - 2023-04-04 00:30 +0200
              Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 16:20 +0200
            Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 16:00 +0200
              Re: Is perl still the No.1 language for sysadmin? rhkramer@gmail.com - 2023-04-08 16:30 +0200
                Re: Is perl still the No.1 language for sysadmin? Greg Wooledge <greg@wooledge.org> - 2023-04-08 18:30 +0200
                  Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 18:40 +0200
                    Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 18:50 +0200
                  Re: Is perl still the No.1 language for sysadmin? "Thomas Schmitt" <scdbackup@gmx.net> - 2023-04-08 19:50 +0200
                    Re: Is perl still the No.1 language for sysadmin? rhkramer@gmail.com - 2023-04-08 21:20 +0200
                      Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 21:40 +0200
                  Re: Is perl still the No.1 language for sysadmin? Max Nikulin <manikulin@gmail.com> - 2023-04-09 05:40 +0200
          Re: Is perl still the No.1 language for sysadmin? Tom Dial <tddial@comcast.net> - 2023-04-04 04:00 +0200
            Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 16:20 +0200
              Re: Is perl still the No.1 language for sysadmin? davidson <davidson@freevolt.org> - 2023-04-08 16:50 +0200
                Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 17:10 +0200
              Re: Is perl still the No.1 language for sysadmin? Tom Dial <tddial@comcast.net> - 2023-04-11 04:20 +0200
            Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 16:30 +0200
          Re: Is perl still the No.1 language for sysadmin? Celejar <celejar@gmail.com> - 2023-04-05 04:10 +0200
            Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 16:50 +0200
    Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-02 23:20 +0200
      Re: Is perl still the No.1 language for sysadmin? ghe2001 <ghe2001@protonmail.com> - 2023-04-02 23:40 +0200
        Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 23:50 +0200
          Re: Is perl still the No.1 language for sysadmin? Michel Verdier <mv524@free.fr> - 2023-04-03 00:10 +0200
      Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-02 23:40 +0200
        Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 05:50 +0200
          Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 20:00 +0200
            Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 20:20 +0200
              Re: Is perl still the No.1 language for sysadmin? Michel Verdier <mv524@free.fr> - 2023-04-03 20:50 +0200
                Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 15:20 +0200
            Re: Is perl still the No.1 language for sysadmin? Michel Verdier <mv524@free.fr> - 2023-04-03 20:20 +0200
            Re: Is perl still the No.1 language for sysadmin? Greg Wooledge <greg@wooledge.org> - 2023-04-03 20:50 +0200
              Re: Is perl still the No.1 language for sysadmin? Michel Verdier <mv524@free.fr> - 2023-04-03 21:00 +0200
                Re: Is perl still the No.1 language for sysadmin? davidson <davidson@freevolt.org> - 2023-04-08 05:50 +0200
                  Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 15:40 +0200
              Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 22:00 +0200
                Re: Is perl still the No.1 language for sysadmin? Greg Wooledge <greg@wooledge.org> - 2023-04-03 22:10 +0200
                  Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 22:30 +0200
                  Re: Is perl still the No.1 language for sysadmin? Michael <ml@hemathor.de> - 2023-04-05 12:00 +0200
                    Re: Is perl still the No.1 language for sysadmin? Michael <ml@hemathor.de> - 2023-04-05 12:00 +0200
                    Re: Is perl still the No.1 language for sysadmin? Nicolas George <george@nsup.org> - 2023-04-05 12:10 +0200
                      Re: Is perl still the No.1 language for sysadmin? Greg Wooledge <greg@wooledge.org> - 2023-04-05 13:30 +0200
                        Re: Is perl still the No.1 language for sysadmin? <tomas@tuxteam.de> - 2023-04-05 13:40 +0200
                          Re: Is perl still the No.1 language for sysadmin? Nicolas George <george@nsup.org> - 2023-04-05 14:00 +0200
                          Re: Is perl still the No.1 language for sysadmin? Greg Wooledge <greg@wooledge.org> - 2023-04-05 14:20 +0200
                        Re: Is perl still the No.1 language for sysadmin? Nicolas George <george@nsup.org> - 2023-04-05 13:40 +0200
            Re: Is perl still the No.1 language for sysadmin? David Christensen <dpchrist@holgerdanske.com> - 2023-04-03 21:50 +0200
    Re: Is perl still the No.1 language for sysadmin? Andy Smith <andy@strugglers.net> - 2023-04-03 05:10 +0200
    Re: Is perl still the No.1 language for sysadmin? Jeffrey Walton <noloader@gmail.com> - 2023-04-03 18:40 +0200
      Re: Is perl still the No.1 language for sysadmin? Stanislav Vlasov <stanislav.v.v@gmail.com> - 2023-04-03 19:10 +0200
        Re: Is perl still the No.1 language for sysadmin? Michel Verdier <mv524@free.fr> - 2023-04-03 19:40 +0200
          Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 19:50 +0200
      Re: Is perl still the No.1 language for sysadmin? debian-user@howorth.org.uk - 2023-04-03 19:20 +0200
        Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 19:50 +0200
      Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-03 19:40 +0200
        Re: Is perl still the No.1 language for sysadmin? "Thomas Schmitt" <scdbackup@gmx.net> - 2023-04-03 20:30 +0200
          Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 15:10 +0200
            Re: Is perl still the No.1 language for sysadmin? Greg Wooledge <greg@wooledge.org> - 2023-04-08 15:20 +0200
              Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 15:30 +0200
          Re: Is perl still the No.1 language for sysadmin? Andy Smith <andy@strugglers.net> - 2023-04-09 00:20 +0200
            Re: Is perl still the No.1 language for sysadmin? conover@panix.com (John Conover) - 2023-04-09 05:00 +0200
        Re: Is perl still the No.1 language for sysadmin? Jeffrey Walton <noloader@gmail.com> - 2023-04-04 15:40 +0200
          Re: Is perl still the No.1 language for sysadmin? Stefan Monnier <monnier@iro.umontreal.ca> - 2023-04-04 15:50 +0200
            Re: Is perl still the No.1 language for sysadmin? Jeffrey Walton <noloader@gmail.com> - 2023-04-04 16:40 +0200
              Re: Is perl still the No.1 language for sysadmin? debian-user@howorth.org.uk - 2023-04-04 19:40 +0200
                Re: Is perl still the No.1 language for sysadmin? Greg Wooledge <greg@wooledge.org> - 2023-04-04 19:40 +0200
                  Re: Is perl still the No.1 language for sysadmin? David Wright <deblis@lionunicorn.co.uk> - 2023-04-04 20:00 +0200
                  Re: Is perl still the No.1 language for sysadmin? Jeffrey Walton <noloader@gmail.com> - 2023-04-04 21:00 +0200
                    Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 16:40 +0200
                  Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 16:40 +0200
                Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 16:50 +0200
            Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 17:00 +0200
          Re: Is perl still the No.1 language for sysadmin? Emanuel Berg <incal@dataswamp.org> - 2023-04-08 17:10 +0200
      Computer anthropology and language wars [was: Is perl still the No.1  language for sysadmin?] <tomas@tuxteam.de> - 2023-04-03 19:50 +0200

Page 5 of 7 — ← Prev page 1 2 3 4 [5] 6 7  Next page →


#256634

Fromghe2001 <ghe2001@protonmail.com>
Date2023-04-02 23:40 +0200
Message-ID<GgdAB-gVih-5@gated-at.bofh.it>
In reply to#256632
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On Amazon, if you ask for books on raku, you get stuff about clay and kilns.  If you ask for python, you get TV programs and snakes.

If you ask for perl, you get Perl.  That's one thing good old Perl has over the new stuff :-)

--
Glenn English


-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wsBzBAEBCAAnBQJkKfPlCRCf14YxgqyMMhYhBCyicw9CUnAlY0ANl5/XhjGC
rIwyAACSrwgAhf+mjUhhvvE29cWAwtizea0qnvhCfQZjDuaGmfEq9iCudtAA
HB+3Xj6OvAcq/ma+FAD3yph1qNQUGLxNtjulqG/2zu32etEW9TdC0QbzrZLD
JPS7cI/TO8X84wSH5qh24HU4k/OrpYQjNeDTbhFOyDKWRmEBpunSDeuYwfSL
w1NGNU2idW1NUd/S25/4H299/ofHPWUjafwemMpXJxC2cqXVFh3RKqMtbIhh
/eeZ0VssegKrxikbt0Vl1EQR2pINvOs9KFJtMRolvF/9gvllK7X0a86zNwlI
IBBGbSNCjSJQBepq1Fso6zWg/PCW5K+H9xjhW3ijA0vExmPnCXpXoA==
=X6X2
-----END PGP SIGNATURE-----

[toc] | [prev] | [next] | [standalone]


#256636

FromEmanuel Berg <incal@dataswamp.org>
Date2023-04-02 23:50 +0200
Message-ID<GgdKh-gVlY-3@gated-at.bofh.it>
In reply to#256634
ghe2001 wrote:

> On Amazon, if you ask for books on raku, you get stuff about
> clay and kilns. If you ask for python, you get TV programs
> and snakes.
>
> If you ask for perl, you get Perl. That's one thing good old
> Perl has over the new stuff :-)

Haha, but haven't you seen like 1 zillion Python books?
Crypto Trade with Python, Game programming in Pygame, blah
blah blah (made up examples but I'm almost sure they exist)

I think I've seen <10 Perl books in my life ... and
I love books!

Hey, inspired by the other dude's awesome list of source code,
can't we have a command to parse Bibtex and find out who has
the more books :)

I don't think Lisp will win anyway, I have these in my own
file, and I know of "CLTL" [1] as well ...

@book{land-of-lisp,
  author    = {Conrad Barski},
  isbn      = {1593272812},
  publisher = {No Starch},
  title     = {Land of Lisp},
  year      = {2010}
}

@book{lispcraft,
  author    = {Robert Wilensky},
  isbn      = {0393954420},
  publisher = {Norton},
  title     = {LISPcraft},
  year      = {1984}
}

[1] https://en.wikipedia.org/wiki/Common_Lisp_the_Language

-- 
underground experts united
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#256639

FromMichel Verdier <mv524@free.fr>
Date2023-04-03 00:10 +0200
Message-ID<Gge3D-gVIg-5@gated-at.bofh.it>
In reply to#256636
Le 2 avril 2023 Emanuel Berg a écrit :

> Hey, inspired by the other dude's awesome list of source code,
> can't we have a command to parse Bibtex and find out who has
> the more books :)

Hum I think win** have even more books, still it's not the thing to learn
for a sysadmin :) I read 1 book on Perl (was in '98, not much internet) and
0 on python.

[toc] | [prev] | [next] | [standalone]


#256635

FromEmanuel Berg <incal@dataswamp.org>
Date2023-04-02 23:40 +0200
Message-ID<GgdAB-gVih-7@gated-at.bofh.it>
In reply to#256632
David Christensen wrote:

> For sysadmin, I *use* what comes on the platform.  On Debian:
>
> 2023-04-02 13:40:08 root@taz ~
> # cat /etc/debian_version ; uname -a
> 11.6
> Linux taz 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1
> (2023-01-21) x86_64 GNU/Linux
>
> 2023-04-02 13:40:17 root@taz ~
> # echo $PATH | tr ':' '\n' | perl -MFile::Slurp -ne
>   'chomp;@e=read_dir($_,prefix=>1); print map "$_\n",@e'|xargs
>   file|perl -pe 's/\S+\s+//'|grep -v 'symbolic link'|perl -pe
>   's/, dynamically linked.+//'|sort|uniq -c|sort -rn
>    1868 ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
>     356 POSIX shell script, ASCII text executable
>     192 Perl script text executable
>      40 Python script, ASCII text executable
>      36 Bourne-Again shell script, ASCII text executable
>      30 setuid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
>      20 ELF 64-bit LSB executable, x86-64, version 1 (SYSV)
>      16 setgid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
>      14 Tcl script, ASCII text executable
>      10 ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux)
>       8 POSIX shell script, UTF-8 Unicode text executable
>       4 Python script, UTF-8 Unicode text executable
>       4 POSIX shell script, ASCII text executable, with very long lines
>       2 a /usr/bin/env sh script, ASCII text executable
>       2 a /bin/mksh script, UTF-8 Unicode text executable
>       2 Python script, ISO-8859 text executable
>       2 Java source, UTF-8 Unicode text
>       2 ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux)
>       2 Bourne-Again shell script, ASCII text executable [...]

Psychedelic! :O

Well done!

Okay, so there is more Perl than Python, but both are
prominent, so maybe and should have an understanding of both
then ... and not so difficult to do, right?

But you change that stuff, or use Perl/Python as glue? If you
are, maybe either works pretty well, ey?

-- 
underground experts united
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#256663

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2023-04-03 05:50 +0200
Message-ID<GgjmF-gYSN-1@gated-at.bofh.it>
In reply to#256635
On 4/2/23 14:38, Emanuel Berg wrote:
> David Christensen wrote:
> 
>> For sysadmin, I *use* what comes on the platform.  On Debian:
>>
>> 2023-04-02 13:40:08 root@taz ~
>> # cat /etc/debian_version ; uname -a
>> 11.6
>> Linux taz 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1
>> (2023-01-21) x86_64 GNU/Linux
>>
>> 2023-04-02 13:40:17 root@taz ~
>> # echo $PATH | tr ':' '\n' | perl -MFile::Slurp -ne
>>    'chomp;@e=read_dir($_,prefix=>1); print map "$_\n",@e'|xargs
>>    file|perl -pe 's/\S+\s+//'|grep -v 'symbolic link'|perl -pe
>>    's/, dynamically linked.+//'|sort|uniq -c|sort -rn
>>     1868 ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
>>      356 POSIX shell script, ASCII text executable
>>      192 Perl script text executable
>>       40 Python script, ASCII text executable
>>       36 Bourne-Again shell script, ASCII text executable
>>       30 setuid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
>>       20 ELF 64-bit LSB executable, x86-64, version 1 (SYSV)
>>       16 setgid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
>>       14 Tcl script, ASCII text executable
>>       10 ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux)
>>        8 POSIX shell script, UTF-8 Unicode text executable
>>        4 Python script, UTF-8 Unicode text executable
>>        4 POSIX shell script, ASCII text executable, with very long lines
>>        2 a /usr/bin/env sh script, ASCII text executable
>>        2 a /bin/mksh script, UTF-8 Unicode text executable
>>        2 Python script, ISO-8859 text executable
>>        2 Java source, UTF-8 Unicode text
>>        2 ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux)
>>        2 Bourne-Again shell script, ASCII text executable [...]
> 
> Psychedelic! :O
> 
> Well done!
> 
> Okay, so there is more Perl than Python, but both are
> prominent, so maybe and should have an understanding of both
> then ... and not so difficult to do, right?
> 
> But you change that stuff, or use Perl/Python as glue? If you
> are, maybe either works pretty well, ey?


The idea of userland tools that read lines of plaintext from standard 
input, write lines of plaintext to standard output, and whose input and 
output streams can be strung together into pipelines was novel at the time:

https://en.wikipedia.org/wiki/Pipeline_(Unix)


On 4/2/23 14:59, Emanuel Berg wrote:
 > Side note, many guys say they only use sh because bash, zsh
 > etc requires them being installed, I don't see how that can be
 > problem on Unix systems. Of course, zsh can't be moved to
 > a computer without zsh itself, but how is that less portable
 > just because they add super-cryptic syntax to do fancy stuff?


AIUI the practice has been to write Bourne shell scripts because nearly 
every Unix or Unix-like system has /bin/sh installed.


Unfortunately, userland tools on different Unix and Unix-like operating 
systems or platforms do not have the same names (paths), do accept the 
same options, do not produce the same output, and/or do not produce the 
same warnings and/or errors.  This includes /bin/sh.


One of my favorite Perl sysadmin tricks is to generate shell commands 
and run them on remote hosts via SSH.  In the past, I have installed 
/bin/bash everywhere to simplify the Perl code.  My current practice is 
to keep the shell commands simple enough so as to avoid the 
incompatibilities.


 > I mean, it isn't the features we port, but the shell?


In this context, I would interpret "port" to mean compiling the shell 
program from source code on a specific operating system or platform. 
So, to run a Zsh script on a given computer, the Zsh program needs to be 
compiled and installed on that computer.  Package managers allow an 
expert to do the former and everyone else to do the latter.


David

[toc] | [prev] | [next] | [standalone]


#256700

FromEmanuel Berg <incal@dataswamp.org>
Date2023-04-03 20:00 +0200
Message-ID<GgwDf-h7kC-1@gated-at.bofh.it>
In reply to#256663
David Christensen wrote:

> # echo $PATH | tr ':' '\n' | perl -MFile::Slurp -ne
>    'chomp;@e=read_dir($_,prefix=>1); print map "$_\n",@e'|xargs
>    file|perl -pe 's/\S+\s+//'|grep -v 'symbolic link'|perl -pe
>    's/, dynamically linked.+//'|sort|uniq -c|sort -rn

I'm still so impressed by this, I tried to run this but it
seems I lack the Slurp module?

Also, if it isn't too much to ask, can you put it in the form
of a script or shell function the way you would? It doesn't
feel right for me to "indent your code" if you follow ...

>> Side note, many guys say they only use sh because bash, zsh
>> etc requires them being installed, I don't see how that can
>> be problem on Unix systems. Of course, zsh can't be moved
>> to a computer without zsh itself, but how is that less
>> portable just because they add super-cryptic syntax to do
>> fancy stuff?
>
> AIUI the practice has been to write Bourne shell scripts
> because nearly every Unix or Unix-like system has
> /bin/sh installed.
>
> Unfortunately, userland tools on different Unix and
> Unix-like operating systems or platforms do not have the
> same names (paths), do accept the same options, do not
> produce the same output, and/or do not produce the same
> warnings and/or errors. This includes /bin/sh.
>
> One of my favorite Perl sysadmin tricks is to generate shell
> commands and run them on remote hosts via SSH. In the past,
> I have installed /bin/bash everywhere to simplify the Perl
> code. My current practice is to keep the shell commands
> simple enough so as to avoid the incompatibilities.

Ah, it is like a biggest denominator which requires no further
installs and can be used everywhere (and in the future) with
no change to it. Good example with ssh, I understand now.

-- 
underground experts united
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#256701

FromEmanuel Berg <incal@dataswamp.org>
Date2023-04-03 20:20 +0200
Message-ID<GgwWB-h7GR-5@gated-at.bofh.it>
In reply to#256700
Michel Verdier wrote:

>> I'm still so impressed by this, I tried to run this but it
>> seems I lack the Slurp module?
>
> apt-get install libfile-slurp-perl

Merci :)

Indeed, works!

Okay, forget about the function/script then, I have it and it
works :)

-- 
underground experts united
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#256704

FromMichel Verdier <mv524@free.fr>
Date2023-04-03 20:50 +0200
Message-ID<GgxpD-h7Rr-5@gated-at.bofh.it>
In reply to#256701
Le 3 avril 2023 Emanuel Berg a écrit :

> Michel Verdier wrote:
>
>>> I'm still so impressed by this, I tried to run this but it
>>> seems I lack the Slurp module?
>>
>> apt-get install libfile-slurp-perl
>
> Merci :)
>
> Indeed, works!
>
> Okay, forget about the function/script then, I have it and it
> works :)

Here it is with some more tests.
Easier to read but much less fun :)

#!/usr/bin/perl -w

use strict;

# echo $PATH | tr ':' '\n' | perl -MFile::Slurp -ne 'chomp;@e=read_dir($_,prefix=>1); print map "$_\n",@e'|xargs file|perl -pe 's/\S+\s+//'|grep -v 'symbolic link'|perl -pe 's/, dynamically linked.+//'|sort|uniq -c|sort -rn

my @folders = split(':',$ENV{PATH});
my %count;

foreach my $folder (@folders) {
    chomp($folder);
    next if(-l $folder);
    print "$folder\n";
    opendir(DIR,"$folder");
    my @files = readdir(DIR);
    closedir DIR;
    foreach my $file (@files) {
        next if($file =~ /^\.\.?$/ or -l "$folder/$file");
        chomp(my $type = `file -b $folder/$file`);
        next if($type =~ /symbolic link/);
        $type =~ s/,.+$//;
        $count{$type}++;
    }
}

foreach my $key (sort {$count{$b} <=> $count{$a}} keys %count) {
    printf("%5d %s\n", $count{$key}, $key);
}

[toc] | [prev] | [next] | [standalone]


#256867

FromEmanuel Berg <incal@dataswamp.org>
Date2023-04-08 15:20 +0200
Message-ID<GigE1-Dst-5@gated-at.bofh.it>
In reply to#256704
Michel Verdier wrote:

> #!/usr/bin/perl -w
>
> use strict;
>
> # echo $PATH | tr ':' '\n' | perl -MFile::Slurp -ne 'chomp;@e=read_dir($_,prefix=>1); print map "$_\n",@e'|xargs file|perl -pe 's/\S+\s+//'|grep -v 'symbolic link'|perl -pe 's/, dynamically linked.+//'|sort|uniq -c|sort -rn
>
> my @folders = split(':',$ENV{PATH});
> my %count;
>
> foreach my $folder (@folders) {
>     chomp($folder);
>     next if(-l $folder);
>     print "$folder\n";
>     opendir(DIR,"$folder");
>     my @files = readdir(DIR);
>     closedir DIR;
>     foreach my $file (@files) {
>         next if($file =~ /^\.\.?$/ or -l "$folder/$file");
>         chomp(my $type = `file -b $folder/$file`);
>         next if($type =~ /symbolic link/);
>         $type =~ s/,.+$//;
>         $count{$type}++;
>     }
> }
>
> foreach my $key (sort {$count{$b} <=> $count{$a}} keys %count) {
>     printf("%5d %s\n", $count{$key}, $key);
> }

First, the syntax is much nicer than Python ...

Question: Can you do everything with Perl, with zsh you can't
and it is annoying and you also feel silly asking people stuff
how you do that and putting them in a position they have to
say "You can't do that". With Lisp you can do everything,
I sort of got used to it, you know what I'm saying?

Check out my Perl BTW, is it any good? Not really, right?
Haha, ah, wrote it to get a job, one thousand years ago, and
didn't get it BTW, back then I always drank one beer before
the interviews to get relaxed, and one energy drink to get
focused LOL

Anyway here

  https://dataswamp.org/~incal/note_DB

So the syntax, maybe that's huge part of not liking
Python intuitively?

Man, to be honest I didn't know this focus on text with Perl,
if I had, maybe I would have done that from the start because
obviously that's something you do all the time.

But OTOH it was fun fiddling with awk, sed, perl ...

Ha, right, let me look that up, 2 instances ...

  perl -e '1 while 1'

What's that's suppose to mean? This file:
  https://dataswamp.org/~incal/conf/.zsh/cpu

And exact same line here (last).

Ah, it's like to stress the processor or something speaking of
CPU instructions.

Anyway what I wanted to say, since text processing is so
fundamental one is maybe recommended to learn great Perl
actually than to collect little fragments from awk, sed, perl
as a shell to LOL, that's why I don't write it with a capital
P, no, but really, I mean superficial use, instead learn
Pearl, in the list should also be included like zsh, not to
mention - I'll not mention them - all the shell tools.

Was it fun fiddling with them? Yes. Did it work? Yes, but not
really fluently. Does it ever? Well ... no :)

#! /bin/zsh
#
# this file:
#   https://dataswamp.org/~incal/conf/.zsh/temp

temp-gov () {
    local t=100

    local cpu
    local cpu_min
    local cpu_max

    perl -e '1 while 1' &
    local pid=$!
    sleep 10

    local i
    local g
    for g in $(cpufreq-info -g); do
        sudo cpufreq-set -g $g
        cpu_min=999
        cpu_max=0
        for i in {0..$t}; do
            cpu=$(sensors -j | jq -a '.["k10temp-pci-00c3"].Tdie.temp1_input')
            (( $cpu < $cpu_min )) && cpu_min=$cpu
            (( $cpu > $cpu_max )) && cpu_max=$cpu
        done
        printf "CPU C (%.2f %.2f) (%d iterations) %s\n" $cpu_min $cpu_max $t $g
    done

    kill $pid
}

temperature () {
    local cpu_min=999
    local gpu_min=999

    local cpu_max=0
    local gpu_max=0

    local cpu
    local gpu

    while true; do
        cpu=$(sensors -j | jq -a '.["k10temp-pci-00c3"].Tdie.temp2_input')
        gpu=$(sensors -j | jq -a '.["nouveau-pci-0100"].temp1.temp1_input')

        (( $cpu > $cpu_max )) && cpu_max=$cpu
        (( $gpu > $gpu_max )) && gpu_max=$gpu

        (( $cpu < $cpu_min )) && cpu_min=$cpu
        (( $gpu < $gpu_min )) && gpu_min=$gpu

        printf "CPU %.1fC (%.1f %.1f)\nGPU %.1fC (%.1f %.1f)\n\n" \
               $cpu $cpu_min $cpu_max                             \
               $gpu $gpu_min $gpu_max
        sleep 1
    done
}
alias {fan,fans}=temperature

-- 
underground experts united
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#256702

FromMichel Verdier <mv524@free.fr>
Date2023-04-03 20:20 +0200
Message-ID<GgwWB-h7GR-7@gated-at.bofh.it>
In reply to#256700
Le 3 avril 2023 Emanuel Berg a écrit :

> I'm still so impressed by this, I tried to run this but it
> seems I lack the Slurp module?

apt-get install libfile-slurp-perl

[toc] | [prev] | [next] | [standalone]


#256705

FromGreg Wooledge <greg@wooledge.org>
Date2023-04-03 20:50 +0200
Message-ID<GgxpD-h7Rr-3@gated-at.bofh.it>
In reply to#256700
On Mon, Apr 03, 2023 at 07:58:03PM +0200, Emanuel Berg wrote:
> David Christensen wrote:
> 
> > # echo $PATH | tr ':' '\n' | perl -MFile::Slurp -ne
> >    'chomp;@e=read_dir($_,prefix=>1); print map "$_\n",@e'|xargs
> >    file|perl -pe 's/\S+\s+//'|grep -v 'symbolic link'|perl -pe
> >    's/, dynamically linked.+//'|sort|uniq -c|sort -rn
> 
> I'm still so impressed by this, I tried to run this but it
> seems I lack the Slurp module?
> 
> Also, if it isn't too much to ask, can you put it in the form
> of a script or shell function the way you would? It doesn't
> feel right for me to "indent your code" if you follow ...

Might be cleaner just to rewrite it from scratch.  Especially since
it mixes multiple invocations of perl together with (unsafe!) xargs and
other shell commands....

Here's a bash version.  It's not fast, but at least it doesn't invoke
perl repeatedly.  (If you're going to invoke perl *at all* you should
simply rewrite the whole thing in perl, IMHO, or at worst have a short
sh script that pipes file's output to one perl invocation.)


#!/bin/bash
shopt -s extglob
IFS=: read -ra paths <<< "$PATH:"
for d in "${paths[@]}"; do
    printf '%s\0' "$d"/*
done |
    xargs -0 file |
    while read -r line; do
        [[ $line = *symbolic\ link* ]] && continue
        line=${line#*:}
        line=${line##+( )}
        line=${line%%, dynamically linked*}
        printf '%s\n' "$line"
    done |
    sort | uniq -c | sort -rn


And its output on my system:

   1485 ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
    358 POSIX shell script, ASCII text executable
    341 Perl script text executable
     63 Bourne-Again shell script, ASCII text executable
     34 Python script, ASCII text executable
     30 ELF 64-bit LSB executable, x86-64, version 1 (SYSV)
     23 setgid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
     15 ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux)
     12 setuid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
     11 POSIX shell script, UTF-8 Unicode text executable
      8 Tcl script, ASCII text executable
      7 Python script, UTF-8 Unicode text executable
      6 ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV)
      5 ASCII text
      3 Python script, ISO-8859 text executable
      3 POSIX shell script, ASCII text executable, with very long lines
      2 setuid, setgid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
      2 POSIX shell script, UTF-8 Unicode text executable, with very long lines
      2 ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV)
      2 Bourne-Again shell script, UTF-8 Unicode text executable
      2 Bourne-Again shell script, ASCII text executable, with very long lines
      1 Tcl/Tk script, ASCII text executable
      1 POSIX shell script, ASCII text executable, with very long lines, with escape sequences
      1 Paul Falstad's zsh script, ASCII text executable
      1 Java source, UTF-8 Unicode text
      1 ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux)
      1 cannot open `/usr/local/games/*' (No such file or directory)
      1 a /usr/bin/env python script executable (binary data)

[toc] | [prev] | [next] | [standalone]


#256706

FromMichel Verdier <mv524@free.fr>
Date2023-04-03 21:00 +0200
Message-ID<Ggxzj-h7UC-1@gated-at.bofh.it>
In reply to#256705
Le 3 avril 2023 Greg Wooledge a écrit :

> Here's a bash version.  It's not fast, but at least it doesn't invoke
> perl repeatedly.  (If you're going to invoke perl *at all* you should
> simply rewrite the whole thing in perl, IMHO, or at worst have a short
> sh script that pipes file's output to one perl invocation.)

perl version:
real	0m7,666s
user	0m2,871s
sys	0m5,054s

bash version:
real	0m23,890s
user	0m24,476s
sys	0m2,113s

whole files are in cache so no io for both.
but you count links, remember /(s)bin can be now a link to /usr/(s)bin

[toc] | [prev] | [next] | [standalone]


#256850

Fromdavidson <davidson@freevolt.org>
Date2023-04-08 05:50 +0200
Message-ID<Gi7Kp-xxy-3@gated-at.bofh.it>
In reply to#256706

[Multipart message — attachments visible in raw view] — view raw

On Mon, 3 Apr 2023 Michel Verdier wrote:
> Le 3 avril 2023 Greg Wooledge a écrit :
>
>> Here's a bash version.  It's not fast, but at least it doesn't invoke
>> perl repeatedly.  (If you're going to invoke perl *at all* you should
>> simply rewrite the whole thing in perl, IMHO, or at worst have a short
>> sh script that pipes file's output to one perl invocation.)
>
[trimmed: performance data]
> whole files are in cache so no io for both.
> but you count links, remember /(s)bin can be now a link to /usr/(s)bin

It took me a while to fully appreciate this observation.

Calling your sweetie Honey-Bunny doesn't make you polyamorous, but
these scripts think it does.

Eg, "/honeybunny/nose" is the same hard link as "/mrsdavidson/nose",
but without subjecting the PATH elements to realpath or something like
it, this fact is ignored.

-- 
It is close to an axiom for me that when rich people expend
considerable sums of other people's money to persuade me something is
good for us, to disbelieve them. -- George Galloway

[toc] | [prev] | [next] | [standalone]


#256871

FromEmanuel Berg <incal@dataswamp.org>
Date2023-04-08 15:40 +0200
Message-ID<GigXn-Dz3-5@gated-at.bofh.it>
In reply to#256850
davidson wrote:

>>> Here's a bash version. It's not fast, but at least it
>>> doesn't invoke perl repeatedly. (If you're going to invoke
>>> perl *at all* you should simply rewrite the whole thing in
>>> perl, IMHO, or at worst have a short sh script that pipes
>>> file's output to one perl invocation.)
>>
> [trimmed: performance data]
>> whole files are in cache so no io for both. but you count
>> links, remember /(s)bin can be now a link to /usr/(s)bin
>
> It took me a while to fully appreciate this observation.
>
> Calling your sweetie Honey-Bunny doesn't make you
> polyamorous, but these scripts think it does.

What do you mean, man?

Only English and technobabble allowed here

-- 
underground experts united
https://dataswamp.org/~incal

[toc] | [prev] | [next] | [standalone]


#256710

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2023-04-03 22:00 +0200
Message-ID<Ggyvn-h8vt-15@gated-at.bofh.it>
In reply to#256705
On 4/3/23 11:47, Greg Wooledge wrote:
> Might be cleaner just to rewrite it from scratch.  Especially since
> it mixes multiple invocations of perl together with (unsafe!) xargs and
> other shell commands....


Please clarify "unsafe" and describe "safe" alternative(s).


David

[toc] | [prev] | [next] | [standalone]


#256711

FromGreg Wooledge <greg@wooledge.org>
Date2023-04-03 22:10 +0200
Message-ID<GgyF4-h8Om-11@gated-at.bofh.it>
In reply to#256710
On Mon, Apr 03, 2023 at 12:50:02PM -0700, David Christensen wrote:
> On 4/3/23 11:47, Greg Wooledge wrote:
> > Might be cleaner just to rewrite it from scratch.  Especially since
> > it mixes multiple invocations of perl together with (unsafe!) xargs and
> > other shell commands....
> 
> 
> Please clarify "unsafe" and describe "safe" alternative(s).

The standard POSIX xargs command is completely unsuitable for use
with filenames as input, for (at least) two reasons:

1) Despite popular belief, xargs does not split input into lines.  It
   splits input into *words*, using any whitespace as delimiters.
   Therfore it fails if any of the input filenames contains whitespace.

   unicorn:~$ echo /stuff/music/Frank_Zappa/15\ The\ Return\ Of\ The\ Son\ Of\ Monster\ Magnet.mp3 | xargs ls -ld
   ls: cannot access '/stuff/music/Frank_Zappa/15': No such file or directory
   ls: cannot access 'The': No such file or directory
   ls: cannot access 'Return': No such file or directory
   ls: cannot access 'Of': No such file or directory
   ls: cannot access 'The': No such file or directory
   ls: cannot access 'Son': No such file or directory
   ls: cannot access 'Of': No such file or directory
   ls: cannot access 'Monster': No such file or directory
   ls: cannot access 'Magnet.mp3': No such file or directory

2) xargs actually uses quotes (single or double) in the input stream to
   delimit words, overriding the whitspace delimiters.  So, a filename
   that contains a quoted section will be handled even more surprisingly:

   unicorn:~$ echo 'foo "bar b q" baz.txt' | xargs ls -ld
   ls: cannot access 'bar b q': No such file or directory
   ls: cannot access 'baz.txt': No such file or directory
   -rwxr-xr-x 1 greg greg 386 Apr  3 14:39  foo

   If the filename doesn't contain a balanced pair of quote marks, then
   it simply explodes.

   unicorn:~$ echo "You can't do that on television.mp4" | xargs ls -ld
   xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
   ls: cannot access 'You': No such file or directory

All together, any filename with whitespace OR a single quote OR a double
quote will break POSIX xargs.

There is no mitigation using the POSIX option set.  None.  At all.  The
command is unsuitable for general use.

The GNU version of xargs, however, adds a -0 option:

       -0, --null
              Input items are terminated by a null  character  instead  of  by
              whitespace,  and the quotes and backslash are not special (every
              character is taken literally).  Disables the end of file string,
              which  is  treated  like  any other argument.  Useful when input
              items might contain white space, quote  marks,  or  backslashes.
              The  GNU  find  -print0  option produces input suitable for this
              mode.

With this option, you can supply a stream of NUL-delimited filenames
to xargs -0, and process them safely.  No explosions will occur, no matter
what filenames are passed.

Feeding filenames to xargs -0 is usually done with either find -print0
(which is another GNU extension, also supported on modern BSD), or with
something equivalent to printf '%s\0'.  Other input sources are possible,
but those are the big two.

[toc] | [prev] | [next] | [standalone]


#256713

FromDavid Christensen <dpchrist@holgerdanske.com>
Date2023-04-03 22:30 +0200
Message-ID<GgyYp-h8Vg-5@gated-at.bofh.it>
In reply to#256711
On 4/3/23 13:03, Greg Wooledge wrote:
> On Mon, Apr 03, 2023 at 12:50:02PM -0700, David Christensen wrote:
>> On 4/3/23 11:47, Greg Wooledge wrote:
>>> Might be cleaner just to rewrite it from scratch.  Especially since
>>> it mixes multiple invocations of perl together with (unsafe!) xargs and
>>> other shell commands....
>>
>>
>> Please clarify "unsafe" and describe "safe" alternative(s).
> 
> The standard POSIX xargs command is completely unsuitable for use
> with filenames as input, for (at least) two reasons:
> 
> 1) Despite popular belief, xargs does not split input into lines.  It
>     splits input into *words*, using any whitespace as delimiters.
>     Therfore it fails if any of the input filenames contains whitespace.
> 
>     unicorn:~$ echo /stuff/music/Frank_Zappa/15\ The\ Return\ Of\ The\ Son\ Of\ Monster\ Magnet.mp3 | xargs ls -ld
>     ls: cannot access '/stuff/music/Frank_Zappa/15': No such file or directory
>     ls: cannot access 'The': No such file or directory
>     ls: cannot access 'Return': No such file or directory
>     ls: cannot access 'Of': No such file or directory
>     ls: cannot access 'The': No such file or directory
>     ls: cannot access 'Son': No such file or directory
>     ls: cannot access 'Of': No such file or directory
>     ls: cannot access 'Monster': No such file or directory
>     ls: cannot access 'Magnet.mp3': No such file or directory
> 
> 2) xargs actually uses quotes (single or double) in the input stream to
>     delimit words, overriding the whitspace delimiters.  So, a filename
>     that contains a quoted section will be handled even more surprisingly:
> 
>     unicorn:~$ echo 'foo "bar b q" baz.txt' | xargs ls -ld
>     ls: cannot access 'bar b q': No such file or directory
>     ls: cannot access 'baz.txt': No such file or directory
>     -rwxr-xr-x 1 greg greg 386 Apr  3 14:39  foo
> 
>     If the filename doesn't contain a balanced pair of quote marks, then
>     it simply explodes.
> 
>     unicorn:~$ echo "You can't do that on television.mp4" | xargs ls -ld
>     xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option
>     ls: cannot access 'You': No such file or directory
> 
> All together, any filename with whitespace OR a single quote OR a double
> quote will break POSIX xargs.
> 
> There is no mitigation using the POSIX option set.  None.  At all.  The
> command is unsuitable for general use.
> 
> The GNU version of xargs, however, adds a -0 option:
> 
>         -0, --null
>                Input items are terminated by a null  character  instead  of  by
>                whitespace,  and the quotes and backslash are not special (every
>                character is taken literally).  Disables the end of file string,
>                which  is  treated  like  any other argument.  Useful when input
>                items might contain white space, quote  marks,  or  backslashes.
>                The  GNU  find  -print0  option produces input suitable for this
>                mode.
> 
> With this option, you can supply a stream of NUL-delimited filenames
> to xargs -0, and process them safely.  No explosions will occur, no matter
> what filenames are passed.
> 
> Feeding filenames to xargs -0 is usually done with either find -print0
> (which is another GNU extension, also supported on modern BSD), or with
> something equivalent to printf '%s\0'.  Other input sources are possible,
> but those are the big two.


Yes, you are right.  Thank you.


The initial one-liner worked because every file in my PATH is a 
conventional Unix file name.  I have upgraded the script to use NUL 
delimiters for input to xargs(1):


Dell Precision 3630:
1 @ Xeon E-2174G
2 @ 16 GB DDR-2666 ECC
1 @ Intel 520 Series SSD 60 GB


2023-04-03 13:17:42 root@taz ~
# cat /etc/debian_version; uname -a
11.6
Linux taz 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 
GNU/Linux


2023-04-03 13:17:46 root@taz ~
# cat /usr/local/bin/survey-path-file
#!/bin/sh
# $Id: survey-path-file,v 1.4 2023/04/03 20:09:47 dpchrist Exp $
# by David Paul Christensen dpchrist@holgerdanske.com
# Public Domain
#
# Run file(1) for files in PATH.  Count and print frequency of results.

echo $PATH \
| tr ':' '\n' \
| perl -MFile::Slurp -ne 'chomp;print map {"$_\0"} read_dir($_,prefix=>1)' \
| xargs -0 file \
| perl -pe 's/\S+\s+//' \
| grep -v 'symbolic link' \
| perl -pe 's/, dynamically linked.+//' \
| sort \
| uniq -c \
| sort -rn


2023-04-03 13:18:19 root@taz ~
# time survey-path-file
    1872 ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
     359 POSIX shell script, ASCII text executable
     192 Perl script text executable
      40 Python script, ASCII text executable
      36 Bourne-Again shell script, ASCII text executable
      30 setuid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
      20 ELF 64-bit LSB executable, x86-64, version 1 (SYSV)
      16 setgid ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV)
      14 Tcl script, ASCII text executable
      10 ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux)
       8 POSIX shell script, UTF-8 Unicode text executable
       4 Python script, UTF-8 Unicode text executable
       4 POSIX shell script, ASCII text executable, with very long lines
       2 a /usr/bin/env sh script, ASCII text executable
       2 a /bin/mksh script, UTF-8 Unicode text executable
       2 Python script, ISO-8859 text executable
       2 Java source, UTF-8 Unicode text
       2 ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux)
       2 Bourne-Again shell script, ASCII text executable, with very 
long lines

real	0m0.714s
user	0m0.623s
sys	0m0.131s


David

[toc] | [prev] | [next] | [standalone]


#256771

FromMichael <ml@hemathor.de>
Date2023-04-05 12:00 +0200
Message-ID<Gh85P-hvEs-1@gated-at.bofh.it>
In reply to#256711
On Monday, 3 April 2023 22:03:59 CEST, Greg Wooledge wrote:
> With this option, you can supply a stream of NUL-delimited filenames
> to xargs -0, and process them safely.  No explosions will occur, no matter
> what filenames are passed.

out of curiosity, why not omit xargs altogether and do someting like:

#!/bin/bash
[...]
    printf '%s\0' "$d"/*
done |
    while read -r -d '' line; do
[...]


or do i miss something?


greetings...

[toc] | [prev] | [next] | [standalone]


#256772

FromMichael <ml@hemathor.de>
Date2023-04-05 12:00 +0200
Message-ID<Gh85P-hvEs-3@gated-at.bofh.it>
In reply to#256771
On Wednesday, 5 April 2023 11:48:35 CEST, Michael wrote:
> or do i miss something?

yes i did!!!

sorry, please ignore my previous post!

greetings...

[toc] | [prev] | [next] | [standalone]


#256773

FromNicolas George <george@nsup.org>
Date2023-04-05 12:10 +0200
Message-ID<Gh8fv-hvXg-5@gated-at.bofh.it>
In reply to#256771
Michael (12023-04-05):
> out of curiosity, why not omit xargs altogether and do someting like:
> 
> #!/bin/bash
> [...]
>    printf '%s\0' "$d"/*
> done |
>    while read -r -d '' line; do
> [...]
> 
> or do i miss something?

1. Your script will execute the command once per argument, xargs will
execute the command only once with all the arguments, or a few times as
possible if the number of arguments is huge.

2. If you are relying on nonstandard shell constructs, then go directly
for zsh and use recursive globbing and glob patterns.

I do not understand how people can bear working with a shell without
recursive globbing, glob patterns and temp file process substitution. My
only conjecture is they do not know about it and never learned their
marvels.

Regards,

-- 
  Nicolas George

[toc] | [prev] | [next] | [standalone]


Page 5 of 7 — ← Prev page 1 2 3 4 [5] 6 7  Next page →

Back to top | Article view | linux.debian.user


csiph-web