On 21 Aug 2024 14:00 +0200, from cor...@free.fr (Corey H):
> I use this command trying to find a file in /etc whose name contains "spf",
> 
> root@cloud:~# cd /etc/
> 
> root@cloud:/etc# ls *spf*
> policyd-spf.conf
> 
> But this file is not listed by 'ls' command.
> 
> # ls /etc/policyd-spf.conf
> ls: cannot access '/etc/policyd-spf.conf': No such file or directory
> 
> instead it's located in a subdir of /etc,
> 
> # cd /etc/postfix-policyd-spf-python/
> # ls policyd-spf.conf
> policyd-spf.conf
> 
> it seems strange to me. does glob will search for subdir but won't return
> its path?

The glob matches the directory. This causes `ls` to get the directory
name on its command line, which makes `ls` list the contents of that
directory.

For the behavior you want, try using `ls -d`. That will list the
matching directory entries (if any) without descending into
directories to list their contents.

Filename globbing is done by the shell, not by the invoked application
(such as `ls`).

-- 
Michael Kjörling                     🔗 https://michael.kjorling.se
“Remember when, on the Internet, nobody cared that you were a dog?”

Reply via email to