On Mon, Sep 30, 2019 at 11:06:19AM -0600, Todd C. Miller wrote:
> On Mon, 30 Sep 2019 18:53:56 +0200, Solene Rapenne wrote:
> 
> > I'm using OpenBSD -current (snapshots from 28 sept) on amd64.
> > I'm not sure this is a bug but I can't find an explanation in the man
> > page.
> >
> > I wanted to remove last field of a string using "-" as separator, but
> > the separator seems to be reset to space ' ' after modifying $NF
> >
> > $ echo "www/p5-Dancer-Plugin-2019" | awk -F'-' '{print; $NF=""; print}'
> > www/p5-Dancer-Plugin-2019
> > www/p5 Dancer Plugin 
> 
> This is due to the output field separator still being a space.  The
> -F option only sets the input field separator.  See OFS in the awk
> manual.
> 
> $ echo "www/p5-Dancer-Plugin-2019" | \
>     awk -F'-' 'BEGIN {OFS="-"} {print; NF--; print  }'
> www/p5-Dancer-Plugin-2019
> www/p5-Dancer-Plugin
> 
>  - todd
> 

thank you for your detailed answer

Reply via email to