On Wed, Aug 21, 2024 at 02:00:02PM +0200, Corey H wrote:
Hi
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?
No, it is not strange. To understand that, you need to remember,
absorb and re-remember: the shell is expanding your *spf* above.
Again: the glob expansion is the shell's job.
So if there is something in your current dir (/etc in this case)
with spf somewhere in its name, it will be *replaced* before ls
can even see it.
In your case, that's the directoy "postfix-policyd-spf-python",
so what ls is, at the end, seeing is
ls postfix-policyd-spf-python
which it dutifully does. Just try "echo" instead of "ls" to see
what I mean.
The real fun begins when you have more than one thing matching
the glob: the shell will expand to a list and "ls" will see the
list. Try
ls /etc/*conf*
then
echo /etc/*conf*
Cheers
--
t
-----BEGIN PGP SIGNATURE-----
iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZsXZdwAKCRAFyCz1etHa RhNKAJ4lKKaMCACYecFRwWv4mD1cr7+NUwCfURyfKwMkFUsPjPZq1XQwTPtxCIw=
=/YQT
-----END PGP SIGNATURE-----
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)