In article <
87io2ny...@bsb.me.uk>,
Ben Bacarisse <
ben.u...@bsb.me.uk> wrote:
...
>The simplest way to remove the first space-delimited field from every
>line, without altering the spaces, is to use sed:
>
> echo " a n" | sed -e 's/[^ ]\+//'
>
>You can do that sort of substitution in Awk but it's not a natural use
>of the tool.
I disagree with that. AWK is a perfectly fine tool for this, and it is
better to just leave sed (and many of the rest of those cute little Unix-y
commands like join, comm, etc) back in the 20th century where it/they
belong.
That said, OP has identified one of the slightly weird bits in AWK, that
does catch up newcomers.
If, indeed, the OP's goal is to safely remove the first field from the record
and print what remains, he could try either of these approaches (alert: may
be gawk-specific):
# This is reg-exp-proof
{ print substr($0,index($0,$1)+length($1)+1) }
or
# Uses reg-exps
{ print gensub($1,"",1) }
Whether or not you want reg-exps in play is up to you; arguments could
favor either position.
--
People seem to think that Youtube (and Facebook and Twitter and so on) is
(are) some sort of resource created for the public good. Why they delude
themselves into believing this is beyond my ability to comprehend.
Usenet will always be here. Longer than people remember what port 80 was for.