find命令找不到我确实存在的文件

陈dy

find遇到一种奇怪的情况,该命令找不到某些文件,但可以找到另一个文件,并且它们都存在于本地路径中。

原始代码作为屏幕截图:

屏幕

文件在那里:

$ 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

但是找不到它们:

$ find ~/.config -name z.lua
$ find ~/.config -name prompt_pwd.fish

上层目录及其中的文件:

$ 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/

这些可以找到:

$ 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

并且以防万一(由于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

find怎么了?

供参考:

  • Ubuntu 16.04.3 LTS amd64
  • 查找(GNU findutils)4.7.0-git, /usr/bin/find
卡米尔·马乔洛夫斯基(Kamil Maciorowski)

~/.config/fish/functions是一个符号链接。因此,它是关于[强调我的]:

-P
切勿遵循符号链接。这是默认行为find检查或打印文件信息时,该文件是符号链接,则所使用的信息应取自符号链接本身的属性。

-L
跟随符号链接。find有关文件检或打印信息,使用信息应在文件的属性采取的链接指向,而不是链接本身[...]。如果-L有效并且find在搜索过程中发现了指向子目录的符号链接,则将搜索该符号链接所指向的子目录

(来源)

使用find -L这是一个选项,而不是操作数;它应该出现在路径之前。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章