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

Re: The ls command



On Thu, 2025-10-30 at 18:32 +0000, debian-user@howorth.org.uk wrote:
The Wanderer <wanderer@fastmail.fm> wrote:
On 2025-10-30 at 13:33, Michael wrote:

The command

ls -- *.pdf

has been run and a very large number of PDF files has been listed.

It is very difficult to spot any strangely named PDF files.

What command should be issued to easily list any strangely named PDF
file ? 

Try:

$ ls -- *.pdf | grep ' -'

This should show you any files whose name include a space followed by
a dash. The space would be treated as a token separator, and the dash
would be treated as the beginning of a new argument to ls.

err no, ls lists multiple files on a line and this wouldn't pick up any
file at the start of a line. grep '--K' is better.

ls lists files one-per-line if its output is piped other than stdout

Try it, e.g. ls | less


If you want to look only for things that might be parsed as
"long-form" options, try the same command except with two dashes in a
row rather than just the one.




Reply to: