Re: The ls command
On Fri, Oct 31, 2025 at 3:01 AM Nicolas George <george@nsup.org> wrote:
> Jeffrey Walton (HE12025-10-31):
> > $ ls ./*.pdf
> > ./--K.pdf
> ^^
> That is a useless “./”.
That ./ prefix isn't at all useless, notably if one doesn't want
any of the arguments to be interpreted as options (leading -)
and if one's command doesn't have/support the --
option (to indicate end of options), or one doesn't want to use that.
However, yes, in that case, e.g. output of ls, the resultant ls output
will then have that ./ prefix on it's listing (unless perhaps, e.g.,
the only match is to exactly one file and one didn't include the -d option).
So, sure, context matters - what one is trying to do and wants to achieve,
and with what.
So, e.g., say one has an implementation of the rm command
that doesn't support -- at all.
And let's say one has a file named exactly this that one wants to remove:
-rf *
Yes, starting with -, with those option letters r, and f, a space, and
literal * character.
So, yeah, something like:
rm -rf *
almost certainly not what one wants, however, highly useful, e.g.:
rm './-rf *'
Reply to: