Solaris 11.3 environment.
Assume you have a directory with the following configuration:
/var/tmp/KOTEI/END/
/var/tmp/Organization Code/END/
The system creates a large number of files under this control, including 0 bytes of files.
I am thinking of automatically deleting this 0 byte file in the shell because it will accumulate nearly 100,000 pieces in a month.
Delete all 0 byte files regardless of the filename.
I have considered the following command, but could you please give me your opinion if there is any problem?
find/var/tmp/KOTEI/END-size 0c-execrm{}\;
find/var/tmp/*/END-size 0c-execrm{}\;
The scariest thing is that you accidentally delete files that contain data that are not 0 bytes.
Also, as the organization is subject to change, I am not sure if I can handle it by making it "/*/".
Thank you very much for your advice.
solaris
No problem.
Solaris find
(1) -exec
can use +
to handle ;
more efficiently, and rm
(1) fires as many files as +
.Read the online documentation for more information.
$find/path/to/target/dir-size 0c-execrm{}+
If you want to check the file to be processed, you can check it beforehand by -exec
, specifying -ls
instead of -exec
, or adding echo
before rm
.
$find/path/to/target/dir-size 0c
...Displays a list of names for files of size 0...
$ find/path/to/target/dir-size 0c-ls
... A list of `ls-l` equivalent files of size 0 appears...
$ find/path/to/target/dir-size 0c-execechorm{}+
... Displays `rm<size 0 set of filenames...>...
© 2024 OneMinuteCode. All rights reserved.