Answer the question
In order to leave comments, you need to log in
How to delete files in a directory without deleting folders?
There are directories with a file, let's say there are directories that make up the path /dir1/dir2/dir3/
. How to delete files in all directories without deleting the directories themselves?
A similar command rm -f /path/to/directory/{*,.*}
cannot be deleted, files are deleted only in one directory.
Answer the question
In order to leave comments, you need to log in
find /dir1 -type f -delete
Find in the folder /dir1
and deeper all occurrences of the type "file" ( -type f
) and delete them ( -delete
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question