Linux empty and delete large file commands of the specified size

Source: Internet
Author: User

Find large files

The code is as follows Copy Code

Find/dir-size +100m-exec LS-LH {}\;

If you want to delete files larger than 50M directly, use the command

The code is as follows Copy Code

find/var/mail/-size +50m-exec rm {}\;

If you want to empty out some text file class things, you can use the

The code is as follows Copy Code

echo "" >/www.111cn.net/xxx.log


This command can achieve the same effect as echo >/var/log/big.log, but after the command is executed, you need to end with Ctrl + D

The code is as follows Copy Code

Clear >/opt/log/big.log

This command empties the contents of the Big.log file without deleting the file
The same effect, with true, Flase, ":" And so on can also achieve empty the contents of the file, without deleting the effect of the file

The code is as follows Copy Code

True >/opt/log/big.log
Flase >/opt/log/big.log
: >/opt/log/big.log

If you want to delete a file, simply use the RM command

The code is as follows Copy Code

Rm-f/opt/log/big.log

If you want to sort folders and files, you can use the

The code is as follows Copy Code

Du-s * | Sort-nr | Head


add two easy ways to use

The code is as follows Copy Code

Cat/dev/null > Files to be emptied

> The files to be emptied

These commands are handy, but use caution to avoid emptying important files.

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.