Since toybox doesn't have its own awk yet (and thus awk '{print $3 $4 $5}'),
back in 2017 toybox added the -D, -F, and -O options to cut:

    -D  Don't sort/collate selections or match -fF lines without delimiter
    -F  Select fields separated by DELIM regex
    -O  Output delimiter (default one space for -F, input delim for -f)

-O is -d for output, -F is a regex version of -f, and -D says to show the raw
matches in the order requested (and ONLY those matches, not passing through
lines with no matches).

This lets you do:

  $ echo one two three four five six seven eight nine | cut -DF 7,1-3,2
  seven one two three two

Elliott Hughes (the Android base OS maintainer) asked if I could get the feature
more widely adopted:

  http://lists.landley.net/pipermail/toybox-landley.net/2021-June/012453.html

> your non-POSIX cut(1) extension covers 80% of the in-the-wild use of awk
> anyway :-) if you still talk to any of the busybox folks, we should suggest
> they copy that --- it would be nice for it to be a de facto standard so we
> can get it into POSIX sometime around the 2040s... (and have made lives
> better for the folks who don't care about standards and just want to "get
> things done" in the intervening decades!)

So I offered to implement it in busybox:

  http://lists.busybox.net/pipermail/busybox/2021-June/088886.html

And the busybox maintainer merged it here:

  https://git.busybox.net/busybox/commit/?id=0068ce2fa0e3

Is there a path to try to get this option set into posix?

Rob

  • cut -DF Rob Landley via austin-group-l at The Open Group
    • Re: cut -DF shwaresyst via austin-group-l at The Open Group

Reply via email to