

find /home/teknotut/dataku/* -mtime +365 -delete To delete certain old files, for example, you want to delete files that were one year old in the /home/teknotut/dataku folder.

Your files in the selected directory will be deleted. rm -f *īe careful when using the command above. If you want to delete all files in the current directory, use the following command. If you want to delete files with data prefix, for example in one directory, you have a file with the name dataaku.txt, your datakamu.xlsx, and you want to delete all files that start with data. txt, use the following command rm -f *.txt Suppose we want to delete all files with the extension. Delete file with Wildcardĭeleting certain files can use wildcards, which are represented by a * ( Asterisk). If you are unsure, you can remove the -f ( force) option. Suppose you want to delete the file aku.txt, kamu.txt in the current directory, use the following command. To delete several files, you only need to separate the file names with spaces. If you use the folder -f ( force) option and its contents, it is immediately deleted without confirmation. Suppose you want to delete my data folder and all its contents, use the following command. To delete a directory, you must use the -r option which means recursive.

The -f option is a force, meaning it doesn't need to be asked, immediately delete it. Sometimes we want to delete the file without being asked. If you are sure, you can press the Y key. You will be asked if you really want to delete the file. The previous command will delete the file with a confirmation. rm /home/teknotut/myfile.txt Delete without Confirmation rm myfile.txtĪlternatively, if you want to delete files with specific directories such as /home/teknotut/aku.txt. Suppose you want to delete the file myfile.txt. Use the following command to delete a single file.
#Linux find file by extension then delete script how to#
Here is how to delete files with the rm command. The rm command is a standard command for deleting files. The commands below apply to all types of Linux, including Raspberry Pi. Here is how to delete files with certain conditions. Or I want to delete files over the age x days. However, what if we want to delete files with certain conditions, for example, the file size is above x MB. Delete files on the Linux Operating System is very easy, with the command rm ( remove) your file can be deleted quickly.
