We have a Kafka production machine on Red Hat Enterprise Linux.
How can we remove all the files under
/var/kafka/kafka-logs
that end with.index
?How can we move all the files that end with
.index
to another folder,/var/tmp/INDEX_BACKUP
?
Example contents under /var/kafka/kafka-logs
:
./hd3gd.ewhd.pri.processed-98/00000000000000000011.index
./hd3gd.ewhd.pri.processed-99/00000000000000000000.index
./hd3gd.ewhd.suspected_relations-0/00000000000000000000.index
./hd3gd.ewhd.suspected_relations-1/00000000000000000000.index
./hd3gd.ewhd.suspected_relations-2/00000000000000000000.index
./hd3gd.ewhd.suspected_relations-3/00000000000000000000.index
./hd3gd.ewhd.suspected_relations-4/00000000000000000000.index
./hd3gd.ewhd.suspected_relations-5/00000000000000000000.index
./frfwjnwe.fwefew.heartbeat-0/00000000000000000000.index
./frfwjnwe.fwefew.heartbeat-1/00000000000000000000.index
./frfwjnwe.fwefew.heartbeat-1/00000000000000017239.index
./frfwjnwe.fwefew.heartbeat-2/00000000000000000000.index
./frfwjnwe.fwefew.heartbeat-2/00000000000000017238.index
-delete
where the deletion is done internally byfind
and would be a lot faster than invoking a separaterm
utility in a child process. It's not faster than-exec rm -f {} +
either which likexargs
runs as fewrm
invocations as necessary. But it has a few problems like: it breaks with file names containing blanks, newlines, quotes..., Ifrm
issues a prompt, it will read the response from the output offind
. – Stéphane Chazelas May 14 '18 at 12:41-exec rm -f {} +
is standard, added to SysV in the mid 80s. In POSIX since 1992. Actually, GNU find was one of the last ones to support it. Solaris definitely supports it.-delete
is a GNU extension (though also supported by a few other implementations now). – Stéphane Chazelas May 14 '18 at 12:55-delete
only in its GNU extension (/usr/gnu/bin/find). Solaris10 has not it preinstalled, admin needs install it. – Sasha Golikov May 14 '18 at 13:01