这是另一个需要解释的bash命令。有人可以解释这个选项对于$ find命令意味着什么意思吗?我知道该命令找到了0字节的文件并将它们丢弃。
$find . – type f –size 0 | xargs rm ls -ld
是什么。意思? 什么是|意思?
做什么 - 输入f - size 0
什么是xargs?什么 - ld是什么意思?
rm =删除 ls = list
答案 0 :(得分:4)
Find有一个参数:用作搜索根目录的目录。所有其他参数都作为选项传递。
find . -type f -size 0
find : The name of the program.
. : The directory to use as the root for the search.
-type f : Find only regular files. (Excludes directories, sym links, etc.)
-size 0 : Finds only empty files.
find命令的输出将是空文件列表。然后将该输出馈入xargs。 xargs是一个程序,它将一个字符串列表作为输入,然后对所有字符串执行给定的命令。
您输入的命令xargs rm ls -ld
似乎有误。我将使用xargs rm
作为示例。
xargs rm
xargs : The name of the program.
rm : The command to run on each file.
因此,完整命令find . -type f -size 0 | xargs rm
找到所有空文件并删除它们。
答案 1 :(得分:3)
.
是当前目录
|
管道一个命令(find)的输出到另一个命令(xargs)的输入
我建议您使用man find
,man xargs
和man ls
来确定find
的选项以及xargs
和{{1}的选项正在做。