Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Find (Unix)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Delete files and directories=== The <code>-delete</code> action is a GNU extension, and using it turns on <code>-depth</code>. So, if you are testing a find command with <code>-print</code> instead of <code>-delete</code> in order to figure out what will happen before going for it, you need to use <code>-depth -print</code>. Delete empty files and print the names (note that <code>-empty</code> is a vendor unique extension from GNU <code>find</code> that may not be available in all <code>find</code> implementations): <syntaxhighlight lang="console"> $ find . -empty -delete -print </syntaxhighlight> Delete empty regular files: <syntaxhighlight lang="console"> $ find . -type f -empty -delete </syntaxhighlight> Delete empty directories: <syntaxhighlight lang="console"> $ find . -type d -empty -delete </syntaxhighlight> Delete empty files named 'bad': <syntaxhighlight lang="console"> $ find . -name bad -empty -delete </syntaxhighlight> Warning. β The <code>-delete</code> action should be used with conditions such as <code>-empty</code> or <code>-name</code>: <syntaxhighlight lang="console"> $ find . -delete # this deletes all in . </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)