find command cannot find my files which do exist
One weird situation occurs to me that find
command cannot find some files but can find another, and they all exist in the local path.
The original code as a screenshot:
.
The files are there:
$ ls -lh ~/.config/fish/functions/
total 92K
-rw-rw-r-- 1 echecod echecod 4.2K Dec 20 16:42 __async_prompt.fish
-rw-rw-r-- 1 echecod echecod 3.0K Dec 20 16:42 done.fish
-rw-rw-r-- 1 echecod echecod 597 Dec 20 16:42 humanize_duration.fish
-rwxrwxr-x 1 echecod echecod 5.2K Dec 20 16:42 __informative_git_prompt.fish*
-rwxrwxr-x 1 echecod echecod 1.4K Dec 20 16:42 prompt_pwd.fish*
-rw-rw-r-- 1 echecod echecod 61K Feb 20 11:38 z.lua
But they cannot be found:
$ find ~/.config -name z.lua
$ find ~/.config -name prompt_pwd.fish
The upper directory and files in it:
$ ls -ld ~/.config/fish/
drwx------ 2 echecod echecod 4096 Feb 20 13:35 /home/echecod/.config/fish/
$ ls -lh ~/.config/fish/
total 24K
lrwxrwxrwx 1 echecod echecod 46 Dec 20 16:45 config.fish -> ../../Dotfiles.d/fish/.config/fish/config.fish*
-rw-r--r-- 1 echecod echecod 1.3K Dec 7 11:00 fishd.DUA-001
-rw-r--r-- 1 echecod echecod 14K Feb 19 18:21 fishd.DUA-BuildServer000
-rw-r--r-- 1 echecod echecod 2.7K Feb 19 10:47 fish_variables
lrwxrwxrwx 1 echecod echecod 44 Dec 20 16:45 functions -> ../../Dotfiles.d/fish/.config/fish/functions/
These can be found:
$ find ~/.config -name config.fish
/home/echecod/.config/fish/config.fish
$ find ~/.config -name fish_variables
/home/echecod/.config/fish/fish_variables
$ find ~/.config -name functions
/home/echecod/.config/fish/functions
And just in case (because of functions -> ../../Dotfiles.d/fish/.config/fish/functions/
):
$ ls -lh ~/Dotfiles.d/fish/.config/fish/functions/
total 92K
-rw-rw-r-- 1 echecod echecod 4.2K Dec 20 16:42 __async_prompt.fish
-rw-rw-r-- 1 echecod echecod 3.0K Dec 20 16:42 done.fish
-rw-rw-r-- 1 echecod echecod 597 Dec 20 16:42 humanize_duration.fish
-rwxrwxr-x 1 echecod echecod 5.2K Dec 20 16:42 __informative_git_prompt.fish*
-rwxrwxr-x 1 echecod echecod 1.4K Dec 20 16:42 prompt_pwd.fish*
-rw-rw-r-- 1 echecod echecod 61K Feb 20 11:38 z.lua
What is wrong with my find
?
FYI:
- Ubuntu 16.04.3 LTS amd64
- find (GNU findutils) 4.7.0-git,
/usr/bin/find
Solution 1:
~/.config/fish/functions
is a symlink. Therefore it's about [emphasis mine]:
-P
Never follow symbolic links. This is the default behaviour. Whenfind
examines or prints information a file, and the file is a symbolic link, the information used shall be taken from the properties of the symbolic link itself.
-L
Follow symbolic links. Whenfind
examines or prints information about files, the information used shall be taken from the properties of the file to which the link points, not from the link itself [...]. If-L
is in effect andfind
discovers a symbolic link to a subdirectory during its search, the subdirectory pointed to by the symbolic link will be searched.
(source)
Use find -L
. This is an option, not operand; it should appear before path(s).