Re: A dream of cut -m
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
Reply to: