|
A situation may occur in your office that you might have to clear the space in the server by deleting the largest files in the log directory. If you want to find and print the top 10 largest files' names (not directories) in a particular directory and its sub directories you can use the following commands.
$ find . -printf '%s %p\n'|sort -nr|head
To restrict the search to the present directory, you can use the parameter "-maxdepth 1" with find command.
$ find . -maxdepth 1 -printf '%s %p\n'|sort -nr|head
And to print the top 10 largest "files and directories":
$ du -a . | sort -nr | head
you can vary the number of files to be printed on the screen by using "head" command as "head -n X" instead of using only "head" in all the above commands to print the top X largest files
$ find . -printf '%s %p\n'|sort -nr|head
To restrict the search to the present directory, you can use the parameter "-maxdepth 1" with find command.
$ find . -maxdepth 1 -printf '%s %p\n'|sort -nr|head
And to print the top 10 largest "files and directories":
$ du -a . | sort -nr | head
you can vary the number of files to be printed on the screen by using "head" command as "head -n X" instead of using only "head" in all the above commands to print the top X largest files
0 Comments:
Post a Comment
Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.
Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.
3. Please do not spam, spam comments will be deleted immediately upon my review.
Regards,
Mohamed Abubakar Sittik A