• Re: A dream of cut -m

    From Geert Stappers@21:1/5 to Kayven Riese on Sat Jun 29 08:40:01 2024
    On Fri, Jun 28, 2024 at 09:50:29PM -0700, Kayven Riese wrote:
    My friend pointed out strange behavior trying to do:

    $ ls -l | cut -d' ' -f7


    -d' ': delimiter is a **single** space character
    -f7: seventh field



    kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src$ ls -l | cut -d' ' -f7

    40829864

    35769753

    93222080

    70233788
    56057072

    May
    Sep



    86001449
    14117396

    22272241





    kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src$ ls -l
    total 723072
    -rw-rw-r-- 1 kayve kayve 40829864 Sep 21 2020 arenalinux_64bit_3.10beta.tar.gz
    drwxr-xr-x 6 kayve kayve 4096 Sep 8 2021 bitcoin-22.0
    -rw-rw-r-- 1 kayve kayve 35769753 Apr 22 2022 bitcoin-22.0-x86_64-linux-gnu.tar.gz
    drwxrwxr-x 17 kayve kayve 4096 Jun 28 18:08 coreutils
    -rwxrwxr-x 1 kayve kayve 93222080 Apr 19 11:06 en-croissant_0.10.0_amd64.AppImage
    drwxrwxr-x 3 kayve kayve 4096 Jan 24 2022 flatiron
    -rw-rw-r-- 1 kayve kayve 70233788 Sep 18 2020 google-chrome-stable_current_amd64.deb
    -rw-rw-r-- 1 kayve kayve 56057072 Jul 28 2020 google-earth.deb
    drwxr-xr-x 4 kayve kayve 4096 Mar 23 2022 LibreOffice_7.3.2.2_Linux_x86-64_deb
    __..........12.3.....4.....5.........6
    -rw-rw-r-- 1 kayve kayve 196010288 May 1 2022 LibreOffice_7.3.2_Linux_x86-64_deb.tar.gz
    field1 3 f4 f5 field6 f7
    -rw-rw-r-- 1 kayve kayve 122102820 Sep 16 2020 Maltego.v4.2.12.13389.deb -rw-rw-r-- 1 kayve kayve 121453 Sep 14 2020 Maltego.v4.2.12.13389.deb.0 -rw-rw-r-- 1 kayve kayve 173677 Sep 14 2020 Maltego.v4.2.12.13389.deb.1 -rw-rw-r-- 1 kayve kayve 35005 Sep 15 2020 Maltego.v4.2.12.13389.deb.2 -rw-rw-r-- 1 kayve kayve 86001449 Sep 15 2020 Maltego.v4.2.12.13389.deb.3 -rw-rw-r-- 1 kayve kayve 14117396 Sep 16 2020 Maltego.v4.2.12.13389.deb.4 drwxrwxr-x 4 kayve kayve 4096 Oct 12 2020 MonoDevelop
    -rw-rw-r-- 1 kayve kayve 22272241 Oct 10 2020 monodevelop_7.8.4.1-0xamarin6+ubuntu1804b1_amd64.deb
    -rw-rw-r-- 1 kayve kayve 1601364 May 25 2021 realtek-rtl8814au-dkms_5.8.5.1~git20210331.bdf80b5-0kali1_all.deb
    -rw-rw-r-- 1 kayve kayve 1795172 May 25 2021 realtek-rtl88xxau-dkms_5.6.4.2~git20210327.c0ce817-0kali2_all.deb
    drwxrwxr-x 2 kayve kayve 4096 Nov 17 2023 Russ_c_programs
    drwxrwxr-x 3 kayve kayve 4096 Nov 30 2023 snort-source-files drwxrwxr-x 2 kayve kayve 4096 Jan 24 2023 WordPress kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src$


    I believe someone suggested using awk instead,

    Yes, awk is aware of white space, one or more space character, as field separator.


    but my friend resisted,

    Her / His choice, her / his problem.


    I guess opting for improving the simpler cut. I have distilled it sufficiently in my mind to have a clear view on this. My friend pointed
    out that if you are using comma separated values and I added /etc/passwd,
    in either case where something like '..::..' or '..,,..' should indicate
    one or more null fields, if you want to separate by whitespace, i.e. one or more spaces, etc., merging consecutive delimiters might be useful, as illustrated by the above example. Therefore, I am in agreement with my friend that adding this -m to merge delimiters option might be nice.

    Acknowledge


    Unfortunately, although I have a good academic background in hacking *NIX
    C, and am able to install various *NIX distros, e.g. BSD, Gentoo, and
    Ubuntu, my ability to get up to speed in being part of a digital community
    is slightly wanting. I am having a hard time installing the coreutils, although I have managed to create a git directory, I am having trouble with compilation, as will be seen below. If anyone has any advice on what I am missing to try to help improve GNU coreutils, I would greatly appreciate
    the advice.


    kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src/coreutils$ git show
    ...
    kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src/coreutils$ make -f cfg.mk
    ...
    make: *** [cfg.mk:61: world] Error 1 kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src/coreutils$


    Untested:

    debcheckout coreutils
    cd coreutils
    debuild

    Upon succesfull build, add your changes plus another

    debuild



    Groeten
    Geert Stappers
    --
    Silence is hard to parse

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eduardo M KALINOWSKI@21:1/5 to Kayven Riese on Sat Jun 29 13:40:04 2024
    On 29/06/2024 01:50, Kayven Riese wrote:
    If anyone has
    any advice on what I am missing to try to help improve GNU coreutils, I
    would greatly appreciate the advice.

    Before you start actively coding, I'd suggest you contact the upstream maintainers[0] and check whether they are interested in this new
    feature, and whether they'd be willing to incorporate your changes.
    coreutils, as the name says, is a very basic part of the GNU/Linux
    ecosystem, so they might be reluctant to accept changes.

    [0] There are some mailing lists listed at https://www.gnu.org/software/coreutils/

    --
    Just remember, wherever you go, there you are.
    -- Buckaroo Bonzai

    Eduardo M KALINOWSKI
    [email protected]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alan M Varghese@21:1/5 to Kayven Riese on Sat Jun 29 13:30:03 2024
    Hi,

    As an FYI, I wanted to chime in with a more reliable way to achieve your desired results without using
    `awk`.

    You could "squeeze" the spaces in the output for `ls` to get a consistent result from `cut`:
    $ ls -l | tr -s ' ' | cut -f7

    Of course, this may fall apart when you consider spaces in the file name itself, where you may
    want to treat different spaces differently.

    Regards,
    Alan M Varghese (NyxTrail)

    On 6/29/24 10:20, Kayven Riese wrote:
    My friend pointed out strange behavior trying to do:

    $ ls -l | cut -d' ' -f7


    kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src$ ls -l | cut -d' ' -f7

    40829864

    35769753

    93222080

    70233788
    56057072

    May
    Sep



    86001449
    14117396

    22272241





    kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src$ ls -l
    total 723072
    -rw-rw-r--  1 kayve kayve  40829864 Sep 21  2020 arenalinux_64bit_3.10beta.tar.gz
    drwxr-xr-x  6 kayve kayve      4096 Sep  8  2021 bitcoin-22.0 -rw-rw-r--  1 kayve kayve  35769753 Apr 22  2022 bitcoin-22.0-x86_64-linux-gnu.tar.gz
    drwxrwxr-x 17 kayve kayve      4096 Jun 28 18:08 coreutils
    -rwxrwxr-x  1 kayve kayve  93222080 Apr 19 11:06 en-croissant_0.10.0_amd64.AppImage
    drwxrwxr-x  3 kayve kayve      4096 Jan 24  2022 flatiron
    -rw-rw-r--  1 kayve kayve  70233788 Sep 18  2020 google-chrome-stable_current_amd64.deb
    -rw-rw-r--  1 kayve kayve  56057072 Jul 28  2020 google-earth.deb drwxr-xr-x  4 kayve kayve      4096 Mar 23  2022 LibreOffice_7.3.2.2_Linux_x86-64_deb
    -rw-rw-r--  1 kayve kayve 196010288 May  1  2022 LibreOffice_7.3.2_Linux_x86-64_deb.tar.gz
    -rw-rw-r--  1 kayve kayve 122102820 Sep 16  2020 Maltego.v4.2.12.13389.deb -rw-rw-r--  1 kayve kayve    121453 Sep 14  2020 Maltego.v4.2.12.13389.deb.0
    -rw-rw-r--  1 kayve kayve    173677 Sep 14  2020 Maltego.v4.2.12.13389.deb.1
    -rw-rw-r--  1 kayve kayve     35005 Sep 15  2020 Maltego.v4.2.12.13389.deb.2
    -rw-rw-r--  1 kayve kayve  86001449 Sep 15  2020 Maltego.v4.2.12.13389.deb.3
    -rw-rw-r--  1 kayve kayve  14117396 Sep 16  2020 Maltego.v4.2.12.13389.deb.4
    drwxrwxr-x  4 kayve kayve      4096 Oct 12  2020 MonoDevelop
    -rw-rw-r--  1 kayve kayve  22272241 Oct 10  2020 monodevelop_7.8.4.1-0xamarin6+ubuntu1804b1_amd64.deb
    -rw-rw-r--  1 kayve kayve   1601364 May 25  2021 realtek-rtl8814au-dkms_5.8.5.1~git20210331.bdf80b5-0kali1_all.deb
    -rw-rw-r--  1 kayve kayve   1795172 May 25  2021 realtek-rtl88xxau-dkms_5.6.4.2~git20210327.c0ce817-0kali2_all.deb
    drwxrwxr-x  2 kayve kayve      4096 Nov 17  2023 Russ_c_programs drwxrwxr-x  3 kayve kayve      4096 Nov 30  2023 snort-source-files drwxrwxr-x  2 kayve kayve      4096 Jan 24  2023 WordPress kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src$


    I believe someone suggested using awk instead, but my friend resisted, I guess opting for improving the simpler cut.  I have distilled it sufficiently in my mind to have a clear view on this.  My friend pointed out that if you are using comma
    separated values and I added /etc/passwd, in either case where something like '..::..' or '..,,..'  should indicate one or more null fields, if you want to separate by whitespace, i.e. one or more spaces, etc., merging consecutive delimiters might be
    useful, as illustrated by the above example.  Therefore, I am in agreement with my friend that adding this -m to merge delimiters option might be nice.

    Unfortunately, although I have a good academic background in hacking *NIX C, and am able to install various *NIX distros, e.g. BSD, Gentoo, and Ubuntu, my ability to get up to speed in being part of a digital community is slightly wanting.  I am
    having a hard time installing the coreutils, although I have managed to create a git directory, I am having trouble with compilation, as will be seen below.  If anyone has any advice on what I am missing to try to help improve GNU coreutils, I would
    greatly appreciate the advice.


    kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src/coreutils$ git show
    commit 05538e9b4c5a0932ce4e65e71a0cc511e3a8b4b7 (HEAD -> master)
    Author: Kayven Riese <[email protected] <mailto:[email protected]>>
    Date:   Fri Jun 28 17:52:43 2024 -0700

        build: update gnulib submodule to latest

    diff --git a/gnulib b/gnulib
    index 15cd8edb6..1066dc9c0 160000
    --- a/gnulib
    +++ b/gnulib
    @@ -1 +1 @@
    -Subproject commit 15cd8edb6ec9aed2585e10456d46eec09d5c1b8b
    +Subproject commit 1066dc9c0bc4ffa65fe117cf055a346482f03b1e kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src/coreutils$ ls
    AUTHORS configure.ac <http://configure.ac>   gnulib-tests  man             README-package-renamed-to-coreutils  tests
    autom4te.cache  COPYING        HACKING       NEWS            README-prereq                        thanks-gen
    bootstrap dist-check.mk <http://dist-check.mk>  init.cfg      po              README-release                       THANKS.in
    bootstrap.conf  doc            lib           README          README-valgrind                      THANKStt.in
    build-aux       gl             m4            README-hacking  scripts                              TODO
    cfg.mk <http://cfg.mk>          gnulib         Makefile.am   README-install  src
    kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src/coreutils$ make -f cfg.mk <http://cfg.mk>
    ./bootstrap && \
    ./configure --quiet && \
    make  -j $(nproc 2>/dev/null || echo 1)
    ./bootstrap: 244: gperf: not found
    ./bootstrap: Error: 'gperf' not found
    ./bootstrap: 314: makeinfo: not found
    ./bootstrap: Error: 'makeinfo' not found
    ./bootstrap: 314: texi2pdf: not found
    ./bootstrap: Error: 'texi2pdf' not found

    ./bootstrap: See README-prereq for how to get the prerequisite programs
    make: *** [cfg.mk:61 <http://cfg.mk:61>: world] Error 1 kayve@kayve-HP-Compaq-Elite-8300-CMT:~/src/coreutils$


    --
      Sincerely,

      Kayven Riese
    *----------------------------------------------------------*
      Kayven Riese, MSCS,
                          MS  (Physiology and Biophysics)
      (415) 902 5513 cellular
      Webmaster http://ChessYoga.org <http://ChessYoga.org> *----------------------------------------------------------*



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)