In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article to share with you is about linux filter empty file command what, Xiaobian think quite practical, so share to everyone to learn, I hope you can read this article after harvest, not much to say, follow Xiaobian to see it.
There are often file operations in linux, today a colleague in the production environment statistics, found that 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}' The above is what Linux filters empty files command, Xiaobian believes that some knowledge points may be our daily work will see or use. I hope you can learn more from this article. For more details, please follow the industry information channel.
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.