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
