How to delete files and subdirectories?

QuestionsQuestions8 SkillsProBasic Files OperationsOct, 03 2025
081

To delete files and subdirectories within a directory, you can use the rm command with the -r (recursive) option. Here’s how you can do it:

rm -r directory_name/*

Replace directory_name with the name of the directory containing the files and subdirectories you want to delete. This command will remove all files and subdirectories within the specified directory.

If you want to delete the directory itself along with all its contents, you can use:

rm -r directory_name

Be cautious when using these commands, as they will permanently delete the specified files and directories without confirmation.

0 Comments

no data
Be the first to share your comment!