In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to filter empty files in Linux, Xiaobian thinks it is very practical, so share it with you as a reference, I hope you can gain something after reading this article.
There are often file operations in Linux, today a colleague in the production environment statistics, found that there are many log files are empty, too many files, he wants to see which files are not empty files.
And also do not want to use scripts, just want to use a command to get it done, really lazy enough of a person. A simple simulation. I just want to check e.lst because its size is not empty.
DUM1102 /oravl01/Oracle> ll *.lst
-rw-r--r-- 1 oracle dba 0 Jul 21 15:39 a.lst
-rw-r--r-- 1 oracle dba 0 Jul 21 15:39 b.lst
-rw-r--r-- 1 oracle dba 0 Jul 21 15:39 c.lst
-rw-r--r-- 1 oracle dba 0 Jul 21 15:39 d.lst
-rw-r--r-- 1 oracle dba 7 Jul 21 15:39 e.lst
The simplest command is to use grep.
DUM1102 /oravl01/oracle> ll *.lst|grep -v " 0 "
-rw-r--r-- 1 oracle dba 7 Jul 21 15:39 e.lst
It can also be done using awk.
The difficulty level is increased again, and a new file f.lst is added. The file structure is now as follows:
DUM1102 /oravl01/oracle> ll *.lst
-rw-r--r-- 1 oracle dba 0 Jul 21 15:39 a.lst
-rw-r--r-- 1 oracle dba 0 Jul 21 15:39 b.lst
-rw-r--r-- 1 oracle dba 0 Jul 21 15:39 c.lst
-rw-r--r-- 1 oracle dba 0 Jul 21 15:39 d.lst
-rw-r--r-- 1 oracle dba 7 Jul 21 15:39 e.lst
-rw-r--r-- 1 oracle dba 14 Jul 21 16:35 f.lst
He now wants to view a file that is 7 bytes in size and uses awk to test the waters.
ll *.lst | awk -v file_size=7 '{ if ( $5==file_size ) print $5 " " $9}'
DUM1102 /oravl01/oracle> ll *.lst | awk -v file_size=7 '{ if ( $5==file_size ) print $5 " " $9}'
7 e.lst
About "Linux how to filter empty files" this article is shared here, I hope the above content can be of some help to everyone, so that you can learn more knowledge, if you think the article is good, please share it to let more people see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.