Linux Basic Tutorial Linux system bulk Delete files with empty file Removal command introduction

Source: Internet
Author: User

Linux Delete file or directory command RM (remove)below:

Brother even Linux Training

Feature Description: Delete files or directories.

Syntax:rm[-dfirv][--help][--version][ file or directory ... ]

Additional note: The Execute RM instruction can delete the file or directory, if you want to delete the directory must add the parameter "-R", otherwise the default will only delete the file.

Parameters

  - D or --directory Delete the hard connection data for the directory that you want to delete directly by deleting the directory by 0.

  - F or --force forces the deletion of files or directories.

   -I or --interactive to ask the user before deleting both files or directories.

  - R or- R or --recursive recursively handles all files and subdirectories under the specified directory.

  - v or --verbose shows the instruction execution process.

  --help online Help.

  How to bulk delete empty files ( Files of size equal to 0 ) under Linux

The code is as follows

  Find. -name "*"-type f-size 0c | Xargs-n 1 rm-f

You can also delete a file of the specified size, as long as you modify the corresponding -size parameter, for example:

The code is as follows

  Find. -name "*"-type f-size 1024c | Xargs-n 1 rm-f

is to delete files of 1k size. ( but be careful not to use -size 1k, this gets to occupy space 1k, not file size 1k ).

If you just delete the folder or the name of the connection, you can change the -type parameters, specific details see man find

Delete N days ago File

  LINUX Bulk Delete files by Time ( delete N days ago file )

The code is as follows

  find/opt/oracle/admin/ccxe/bdump/-mtime +10-name "* *"-exec RM-RF {};

  /opt/oracle/admin/ccxe/bdump/: Any directory that you want to clean up

  -mtime: Standard statement notation

  +10: Find the file of ten days ago, where the number represents the number of days ,+30 means to find the file of the day before

  "*. *": The type of data you want to find,"*.jpg" means looking for all files with the extension jpg ,"*" means finding all files

  -exec: fixed notation

  RM-RF: Forcibly deleting files, including directories

  {} ;  : fixed notation, pair of curly braces + space +/+;

Delete Files completely

Sometimes we have to completely delete some files, you can use the Shred command to implement,shred is a part of the coreutils , so Linux basically will have this command.

  Shred How to delete files completely :

The code is as follows

  $ shred-u File

  Shred will overwrite the node and data block where the file resides with some random content, and delete the file (-u parameter ).

If you want to clear a bit more thoroughly you can add the- z parameter, which means to fill with random data, and then fill it with 0 .

The code is as follows

  $ shred-u-Z File

In addition Shred can also clear the entire partition or disk, such as to completely clear the contents of the /DEV/SDB1 partition can be :

  $ SHRED/DEV/SDB1 ( note Do not add- u parameter )

  Detailed parameters of the shred :

  -F,--force Change permissions allow Write ( if necessary )

  -N ,--iterations=n rewrite n times, default is 3 times

  --random-source=file reading data from a specified file

  - S,--size=n the file to a fixed size ( suffixes such as K,M,C , etc. can be used )

  -U,--remove truncate and remove files after rewriting

  -V,--verbose Show Progress

  -Z,--zero-add with 0 coverage Data

  Help Display Help

  –version displaying version information



Linux Basic Tutorial Linux system bulk Delete files with empty file Removal command introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.