GNU bug report logs - #23922
cut fails for non-delimited input lines with -f 2

Previous Next

Package: coreutils;

Reported by: Jens Mueller <jens.k.mueller <at> gmx.de>

Date: Fri, 8 Jul 2016 23:37:01 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 23922 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Jens Mueller <jens.k.mueller <at> gmx.de>
Cc: 23922 <at> debbugs.gnu.org
Subject: Re: bug#23922: cut fails for non-delimited input lines with -f 2
Date: Fri, 8 Jul 2016 23:20:10 -0400
tag 23922 notabug
close 23922
stop

Hello Jens,

> On Jul 8, 2016, at 19:05, Jens Mueller <jens.k.mueller <at> gmx.de> wrote:
> 
> $ echo "abc" | cut -f 2 -d " "
> 
> and I expect the empty line as output but you get "abc\n".

It is not a bug, but correct behavior (though perhaps unexpected) to print "abc" in this case.

The POSIX standard says (at
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cut.html):
"-s
Suppress lines with no delimiter characters, when used with the -f option. Unless specified, lines with no delimiters shall be passed through untouched."

In GNU cut's help screen (cut --help) shows:
  -s, --only-delimited    do not print lines not containing delimiters

The following will demonstrate:

  $ printf "abc\nd f\n" | cut -f2 -d " "
  abc
  f

  $ printf "abc\nd f\n" | cut -s -f2 -d " "
  f

As such, I'm closing this bug report - but discussion can continue by replying to this thread.

regards,
  - assaf









This bug report was last modified 6 years and 206 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.