[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: The ls command



On Fri, Oct 31, 2025 at 04:26:06 +0100, Vincent Lefevre wrote:
> On 2025-10-30 17:39:33 +0000, alain williams wrote:
> > There was complaint about an option 'K' in the error message, try:
> > 
> > ls -- *.pdf | grep K
> 
> That's a strange use of grep. Simpler:
> 
> ls -- *K*.pdf

This whole thread is insane.

The goal of the grep was to find the offending file, which is to say,
the file that caused the initial complaint.

In other words, the file whose name begins with a hyphen.  There is
no other way to produce the original error message given the original
command.  There *must* be a file whose name starts with a hyphen.

To find the file(s) whose name begins with a hyphen, just use this:

    ls -- -*

hobbit:~$ ls -- -*
ls: cannot access '-*': No such file or directory
hobbit:~$ touch $'./--K\'\n.pdf'
hobbit:~$ ls -*
ls: unrecognized option '--K'
.pdf'
Try 'ls --help' for more information.
hobbit:~$ ls -- -*
'--K'\'''$'\n''.pdf'

That's the closest I can come to reproducing the original error message.


Reply to: