To delete all files in a directory on a Unix or Linux system, you can use the rm
command with the *
wildcard.
The *
wildcard is a special character that matches any number of characters, including none. When used with the rm
command, it will match all files in the specified directory.
For example, to delete all files in the directory /tmp
, you can use the following command:
rm /tmp/*
This will delete all files in the /tmp
directory, but it will not delete any subdirectories or symbolic links.
It is important to note that the rm
command is a powerful utility that can delete files and directories permanently, and it does not have an "undo" option. Therefore, it is important to use the rm
command carefully and make sure that you do not accidentally delete important files or directories.
The rm
command also has several options that allow you to customize the behavior of the command. For example, you can use the -f
option to force the delete operation, or the -i
option to prompt for confirmation before deleting each file.
For more information about the rm
command and its options, you can consult the documentation for your specific Unix or Linux system.