GNU bug report logs - #21636
a question of the “wc” program

Previous Next

Package: coreutils;

Reported by: JameDam <te <at> dam.moe>

Date: Tue, 6 Oct 2015 15:12:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 21636 in the body.
You can then email your comments to 21636 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#21636; Package coreutils. (Tue, 06 Oct 2015 15:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to JameDam <te <at> dam.moe>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 06 Oct 2015 15:12:02 GMT) Full text and rfc822 format available.

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

From: JameDam <te <at> dam.moe>
To: bug-coreutils <at> gnu.org
Subject: a question of the “wc” program
Date: Tue, 06 Oct 2015 18:49:30 +0800
[Message part 1 (text/html, inline)]

Added tag(s) notabug. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Tue, 06 Oct 2015 16:02:03 GMT) Full text and rfc822 format available.

Reply sent to Eric Blake <eblake <at> redhat.com>:
You have taken responsibility. (Tue, 06 Oct 2015 16:02:03 GMT) Full text and rfc822 format available.

Notification sent to JameDam <te <at> dam.moe>:
bug acknowledged by developer. (Tue, 06 Oct 2015 16:02:04 GMT) Full text and rfc822 format available.

Message #12 received at 21636-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: JameDam <te <at> dam.moe>, 21636-done <at> debbugs.gnu.org
Subject: Re: bug#21636: a question of the “wc” program
Date: Tue, 6 Oct 2015 10:01:15 -0600
[Message part 1 (text/plain, inline)]
tag 21636 notabug
thanks

On 10/06/2015 04:49 AM, JameDam wrote:
> I have a file which is named *“-l”*, and I use the wc to count the file, 
> undesirably wc requested the standard input rather than my file *"-l"* ,although 
> I use it through the command
> */wc -lw -l/*

Try either of:

wc -lw -- -l
wc -lw ./-l

This is not a bug in wc.  Rather, it is a FAQ:
https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#I-have-a-file-called-_002d_002dhelp_002e-How-do-I-remove-it_003f

And like most utilities, using an explicit -- to mark the end of
options, or spelling your file name with a leading ./ so that it can't
be confused with an option, will do the trick.

Therefore, I'm closing this as not a bug, although you should feel free
to add any further comments or questions to this thread.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#21636; Package coreutils. (Tue, 06 Oct 2015 19:39:02 GMT) Full text and rfc822 format available.

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

From: Stephane Chazelas <stephane.chazelas <at> gmail.com>
To: 21636 <at> debbugs.gnu.org, eblake <at> redhat.com, te <at> dam.moe
Subject: Re: bug#21636: a question of the “wc” program
Date: Tue, 6 Oct 2015 20:38:27 +0100
2015-10-06 10:01:15 -0600, Eric Blake:
> tag 21636 notabug
> thanks
> 
> On 10/06/2015 04:49 AM, JameDam wrote:
> > I have a file which is named *“-l”*, and I use the wc to count the file, 
> > undesirably wc requested the standard input rather than my file *"-l"* ,although 
> > I use it through the command
> > */wc -lw -l/*
> 
> Try either of:
> 
> wc -lw -- -l
> wc -lw ./-l
> 
> This is not a bug in wc.  Rather, it is a FAQ:
> https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#I-have-a-file-called-_002d_002dhelp_002e-How-do-I-remove-it_003f
> 
> And like most utilities, using an explicit -- to mark the end of
> options, or spelling your file name with a leading ./ so that it can't
> be confused with an option, will do the trick.
[...]

Or:

wc -lw < -l

which in this case also has the benefit of not outputting the
file name.

Note that:

wc -lw -- "$file"

Doesn't work for a file called "-".

wc -lw < -
wc -lw ./-

are OK.

-- 
Stephane




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 04 Nov 2015 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 231 days ago.

Previous Next


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