UNIX / Linux: Delete All Files Using rm Command

https:/‮al.www/‬utturi.com
UNIX / Linux: Delete All Files Using rm Command

To delete all files in a directory on a Unix-like system, you can use the rm command with the * wildcard. Be very careful when using this command, as it will delete all files in the specified directory without prompting for confirmation.

Here's the basic syntax:

rm /path/to/directory/*

Replace /path/to/directory with the path to the directory you want to delete the files from.

For example, to delete all files in the current directory, you can use the following command:

rm *

This will delete all files in the current directory, but will not delete any subdirectories or their contents.

It's important to be careful when using the rm command, as it can delete important system files and cause problems on your system. Make sure you understand the risks and use caution when running this command.

If you want to delete all files and directories in a directory, including subdirectories and their contents, you can use the rm command with the -rf options. This command can be dangerous and should be used with caution.

rm -rf /path/to/directory
Created Time:2017-10-30 14:27:23  Author:lautturi