我想删除文件的所有符号链接。我有一个目录结构/usr/local/instantclient/11.2.0.3,其中包含许多文件,并且我有这些文件的符号链接/usr/local/lib/现在我想删除这些文件的所有这些符号链接。我怎样才能在一个命令中做到这一点。如果我删除/usr/local/instantclient/11.2.0.3包含文件的实际目录,那么它会将断开的链接留在/usr/local/lib.
Pet*_*r H 13
要删除链接(从man find下-type):
l symbolic link; this is never true if the -L option or the
-follow option is in effect, unless the symbolic link is
broken. If you want to search for symbolic links when -L
is in effect, use -xtype.
Run Code Online (Sandbox Code Playgroud)
我认为这应该可以解决问题:
find /usr/local/lib/ -maxdepth 1 -follow -type l
Run Code Online (Sandbox Code Playgroud)
输出是否会生成您要删除的文件列表?如果是这样,当您 100% 确定时:
find /usr/local/lib/ -maxdepth 1 -follow -type l -delete
Run Code Online (Sandbox Code Playgroud)
这将仅删除损坏的链接。要删除所有链接,请删除该-follow节,但我不会在/usr/local/lib.
| 归档时间: |
|
| 查看次数: |
13249 次 |
| 最近记录: |