سؤال

I want to know how I can remove all the files in a directory say directory1 contains some 100 files. I just want to remove the files and not the directory.

I know that rmdir directory1 will remove directory1 completely. But I want to only remove all the files inside.

هل كانت مفيدة؟

المحلول

Try this:

rm /path/to/directory1/*

by adding the -r option you can additionally remove contained directories and their content recursively.

نصائح أخرى

  find /path/to/directory1 -type f | xargs rm -f

This recursively deletes all normal files in the directory.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top