ton*_*_pt 3 linux symbolic-link
我有一个包含代码文件和可执行文件的目录,我想知道如何创建仅指向该目录中可执行文件的符号链接?
我知道path-of-directory/*
选择所有文件,但我只想要可执行文件。
您可以使用find
列出可执行文件:
find /foo -type f -executable
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用该-exec
选项来创建链接。
-exec command ;
Execute command; true if 0 status is returned. All following
arguments to find are taken to be arguments to the command until
an argument consisting of `;' is encountered. The string `{}'
is replaced by the current file name being processed everywhere
it occurs in the arguments to the command [...]
Run Code Online (Sandbox Code Playgroud)
因此,要创建指向 中~/bar
每个可执行文件的链接~/foo
,您可以这样做
find ~/foo -type f -executable -exec ln -s {} ~/bar \;
Run Code Online (Sandbox Code Playgroud)
请注意,这不是搜索二进制文件,只是搜索那些设置了可执行位的文件。
归档时间: |
|
查看次数: |
1084 次 |
最近记录: |