How to Delete Multiple Files in Linux?

How to Delete Multiple Files in Linux?

Posted on

Now we have shared numerous articles that illustrate SSH instructions and their features. At this time, on this tutorial we’ll clarify the process to delete a number of information in Linux.

dmfl
Delete A number of Information in Linux

On this article, we’ll undergo the next.

  1. Command to delete multiple files
  2. Command to delete multiple files accessed before
  3. Command to delete multiple files with same keyword
  4. Command to delete multiple files of same extension
  5. Command to delete files of certain size

Now, allow us to undergo every command one after the other.

#1. Command to delete a number of information

Execute the beneath given command to delete a number of information in Linux.

rm -v filename1 filename2 filename3

Exchange filename1, filename2 & filename3 with the information which you wish to delete or take away.

#2. Command to delete a number of information accessed earlier than

  • Delete information in a listing accessed earlier than explicit date

Execute the beneath command to delete all of the information modified or accessed earlier than explicit date and time within the present working listing.

discover . -kind f ! -newerat 'dd/mm/yyyy 17:24:00' -exec rm -f {} ;

You may modify the date & time within the above given command.

  • Delete information in a listing accessed earlier than explicit day

The beneath given command will enable you to delete or take away information modified or accessed earlier than explicit days.

discover path/of/the/file -type f -mtime +30 -delete 

+30 within the above command represents the times. You may change as per your requirement, i.e, if you wish to delete a number of information accessed earlier than 10 days then +30 would get replaced with +10 within the above command.

#3. Command to delete a number of information with identical key phrase

With the command beneath you may delete all of the information in a listing having identical filename key phrase. This implies when you’ve got a number of information having key phrase  new then you should utilize the beneath given command to delete them unexpectedly.

rm -v key phrase*
discover -type f -name '*key phrase*' -delete

Exchange the key phrase in above command with the one you wish to delete.  Meaning if you wish to delete all of the information having new of their filename, then you want to new rather than key phrase in above command.

#4. Command to delete a number of information of identical extension

The beneath command will delete a number of information with identical extension. This may be executed in two methods.

  • Delete information of identical extension in a listing by utilizing the beneath command.
discover path/of/the/file -type f -name "*.php" -exec rm -f {} ;
  • Delete information of identical extension modified or accessed earlier than explicit days.
discover path/of/the/file -name "*.php" -type f -mtime +30 -delete 

#5. Command to delete information of sure dimension

With the beneath command you may delete information of sure dimension.

  • Delete information bigger than 70MB within the present working listing
discover path/of/the/file -type f -size +70M -exec rm -f {} ;
  • Delete information smaller than 5MB within the present listing
discover path/of/the/file -type f -size -5M -exec rm -f {} ;

You may modify the dimensions of the file as per your selection.

That’s It !

Hope the article higher describes the process to delete a number of information in Linux. Do share it along with your colleagues when you discover it working. Additionally share your ideas and drop your queries to begin the dialogue on the associated matter. Lets join on social media with the beneath hyperlinks.

Fb Web page: https://facebook.com/redserverhost                                                                                       Twitter Web page: https://twitter.com/redserverhost.com



offshore vps