相关疑难解决方法(0)

为什么 bash 完成符号链接与目录不同?

我通常find在搜索源代码时使用环境变量作为路径。最近我用符号链接替换了我的环境变量,它破坏了 Bash 的 shell 完成。当我find使用符号链接时,它不起作用,但如果我使用符号链接指向的实际路径,它会找到。

ln -s /some/source/dir /the/source
export SYMLINK=/the/source
export DIR=/some/source/dir

find $SYMLINK -name file.c        // doesn't find anything
find $DIR -name file.c            // works as expected
Run Code Online (Sandbox Code Playgroud)

在此示例中,$SYMLINK 是 $DIR 值的符号链接。

那么,为什么 bash 以不同的方式处理符号链接环境变量?

find utilities symlink

6
推荐指数
1
解决办法
2252
查看次数

为什么用 `pwd` 查找找不到现有文件,但用 find dot 找到?

这很奇怪:

$ ls -l 'Lana Del Rey - Blue Jeans (Remastered 2011).mp3'
-rw-rw-r-- 1 gigi gigi 4.0M Dec 11 23:06 'Lana Del Rey - Blue Jeans (Remastered 2011).mp3'

$ find . -name 'Lana Del Rey - Blue Jeans (Remastered 2011).mp3'
./Lana Del Rey - Blue Jeans (Remastered 2011).mp3

# but still in the same directory:
$ find `pwd` -name 'Lana Del Rey - Blue Jeans (Remastered 2011).mp3'
# nothing found!
# directly using the path pointed by pwd will produce …
Run Code Online (Sandbox Code Playgroud)

find file-management

0
推荐指数
1
解决办法
340
查看次数

标签 统计

find ×2

file-management ×1

symlink ×1

utilities ×1