ron*_*elt 6 tcsh find shell-builtin
由于工作环境的原因,我只能在 CentOS 上的 tcsh 中执行此操作。执行时find . -type f -executable -exec source '{}' \;
,唯一的结果是find: 'source': No such file or directory
针对每个适当的文件。不知道为什么这在 tcsh 中不起作用,因为它非常简单。我究竟做错了什么?非常感谢任何帮助。
source
是一个内置的shell。find
执行命令。它不能执行内置的 shell。
如果要执行外部程序,只需指定程序名称:
find . -type f -executable -exec '{}' \;
Run Code Online (Sandbox Code Playgroud)
如果这些都是缺少shebang 之类的csh 脚本(#!/bin/env csh
作为第一行),请添加一个 shebang 行。如果您实在无法添加shebang 行,请显式调用csh:
find . -type f -executable -exec tcsh '{}' \;
Run Code Online (Sandbox Code Playgroud)
如果这些都是你想在当前 shell 中执行的 csh 脚本片段,你不能这样做。您需要收集名称,find
然后获取它们。
foreach fragment ("`find . -type f -executable -print`")
source "$fragment"
end
Run Code Online (Sandbox Code Playgroud)
首先,这个要求有些可疑。旨在获取的 Shell 片段不应该是可执行的。
417*_*754 -3
看看这个:
127:2:1389633116:user@host:~$ tcsh source foo
source: No such file or directory.
1:3:1389633119:user@host:~$ tcsh
host:~> source foo
foo: No such file or directory.
host:~> exit
0:4:1389633582:user@host:~$ tcsh -c 'source foo'
foo: No such file or directory.
Run Code Online (Sandbox Code Playgroud)
自己和其他人尝试一下。也许是检查strace
痕迹。最后尝试利用并建立一个解决方法。