The find tool includes the current directory:
~~~
$ find /var -maxdepth 1
/var
/var/cache
/var/lib
/var/log
/var/run
/var/tmp
$ cd /var
$ find -maxdepth 1
.
./cache
./lib
./log
./run
./tmp
~~~
and the ls tool has an option for it:
~~~
$ ls -a /var
. .. cache lib log run tmp
$ cd /var
$ ls -a
. .. cache lib log run tmp
~~~
Pedantic: the "-a" option for ls also shows the parent directory ".." and includes hidden (dot) files.
What is the use case for this?
Closing this, as there is no further feedback.
@sharkdp apologies - i didnt realize feedback was needed
we already have -H to cover hidden items, so we only need to deal with . and
..
we could introduce an option -n, my preference would be that -n will list
. but not .., so that using -H -n would give you a find like output
please reopen - thank you
Ok. Could you please tell us what your use case is?
Just because another program does something a certain way, doesn't necessarily mean it is valuable. Adding functionality just because that's the way find does it seems like wasted effort to me. Personally I have never needed find or ls to include the current directory, and have sometimes had to exclude it when piping it to another command.
Have you found that functionality useful? If so, for what kind of things?
Ok, I'm going to close this for now. I still don't see the need for this, and there are simple ways to work around this in scripting (echo "."; fd ...)
@sharkdp I remembered my use case - ok with find say you want to operate on a subtree, you can do this:
~sh
$ find gamma
gamma
gamma/delta
gamma/epsilon.txt
~
and then
~sh
find gamma -exec SOMETHING
~
and it will operate on everything including gamma - but FD cant do this, see:
~sh
$ fd --search-path gamma
gamma\delta
gamma\epsilon.txt
~
so can we reopen this issue?
Sorry to be insistent here: what is SOMETHING in this case? What kind of command do you apply to every file and directory within a given directory? Thinks like chmod and chown have -R arguments.
@sharkdp i would really rather not divulge, as i dont want this issue to be pigeonholed or judged on just the basis of whatever specific example i give, as i feel strongly that this is a general and valid issue however one use case might be:
~
find gamma -exec touch {} +
~
again this isnt a great example but i dont think original issue should be judged on a specific example
Ok, let's keep this open for a while and try to get some other opinions.