IDO老徐,在深圳,某上市公司质量部负责人,干了十二年软件测试,公号"简尚" ,博客isTester.com ,关注「软件测试从业者综合能力提升」,微信957863300

Linux下常用的查找命令,提升效率

上一篇 / 下一篇  2019-10-10 14:32:52 / 个人分类:linux


n0B;pJ\0

前置条件

'W,PS rCA#S0

51Testing软件测试网:b/o"lp7w(u

创建一个1G的文件51Testing软件测试网6a Ae c3v+m,`

fallocate -l 1g istester.com.ini

~})O&m ?m~8h^N0


51Testing软件测试网X F)RnB%Aq l


feo9C!k6n}0

51Testing软件测试网C _[Bv4mW%kk

找出当前目录,及其子目录中,大于100M的所有文件51Testing软件测试网6Ren;]~'Ru


c'jM.Uxw N0

find ./ -type f -size +100M51Testing软件测试网l{,t%H1A.u Rc


51Testing软件测试网R/pQg.p)F~?#u


51Testing软件测试网O^(ug3ZCaR

大于1G

PU@U8W!L0


51Testing软件测试网5r)h n!L"[q+A

find ./ -type f -size +1G51Testing软件测试网4oN E*gs9r2Ee:f


51Testing软件测试网~jmPCD[EW


Xn dj7Lbv0

延伸,51Testing软件测试网6Q8oubP zJ

\ y7an,tB0

查找isTester目录下,两层目录内(包含2层子文件夹内的文件),所有大于10M的文件

?S.dlG x2OK+k0

find ./isTester -maxdepth 2 -size +10M51Testing软件测试网 Ri? `'@~/m?


*_d.G+E'qkq0


51Testing软件测试网&L(EM!}oM3dcf

51Testing软件测试网GK&tN6l[[

#倒序显示当前路径下,所有大于1M的文件

H6n$^jS0

du -sh ./isTester/* |grep M|sort -nr51Testing软件测试网,b0?]fKj!Z


51Testing软件测试网cDt7~3C:x!y(A*L{


51Testing软件测试网Qv+Q1| w i"y w3X

查找当前目录下,所有1级空目录,并删除51Testing软件测试网I-EWP;\

find ./ -maxdepth 1  -type d -empty | xargs rm -rf

6[?!\w$x{5gFc0

51Testing软件测试网j|/hgg{

find ./ -maxdepth 1  -type d -empty -exec rm -rf {} \;

j(x%?UuS0


51Testing软件测试网` {'hU Hx#?'s


51Testing软件测试网h%Fn6[3K7f8r p

51Testing软件测试网 PiE+B7Nd{

#查找isTester目录下,所有的jpg文件,并压缩为isTester_images.tar.gz

.m#\xH7J1j)]0

find ./isTester -type f -name "*.jpg" | xargs tar -czvf isTester_images.tar.gz

+c}.bG9y0


51Testing软件测试网~vuM'M{_Z|.B


51Testing软件测试网3ho)C!t*?z$^2~:R

#查找isTester目录下,所有的log文件,并复制到当前的idoxu目录51Testing软件测试网~3rAD zIF"^

find ./isTester -type f -name "*.log" -exec cp -rf {} idoxu/ \;51Testing软件测试网9l6z0~2x J |v z5u


S V'v%g6Mg;xZ2Q0


51Testing软件测试网7h8Ms'V*ZJZ0J*c#H

查找包含xx内容的,所有xx文件

6] P:`/PZgx:l pPR A0

find ./* -name 'config.xml' | xargs grep "isTester"

2?@5Q hx4N6FJ0


51Testing软件测试网'_hD'a%{"XF4vXK


I\"w7^n'|5W!a8[0


在/root/isTester目录下查找更改时间在5日以内的文件 

G5OsHE7D0

find /root/isTester/ -mtime -5

b K"}:^"@G%^f^0在/root/isTester目录下查找更改时间在3日以前的文件


9UX,D"j?UCTN0

find /root/isTester/ -mtime +351Testing软件测试网hhc!wK

51Testing软件测试网Z V'i B#y Y%M;e

\ DwL%g y!{0

51Testing软件测试网H8} til%El

;}%T ]&Q(J1ehg0

作者:IDO老徐51Testing软件测试网9^2f(Ik[hH"h

原文链接http://istester.com/linux/312.html51Testing软件测试网_.w]X+|d6w |*HBd'K


TAG:

 

评分:0

我来说两句

xuquan

xuquan

IDO老徐,坐标深圳,测试经理,干了十年测试,公号"简尚" ,个人博客isTester.com ,关注「软件测试从业者综合能力提升」,微信957863300

日历

« 2024-04-25  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 914687
  • 日志数: 427
  • 建立时间: 2012-06-04
  • 更新时间: 2022-02-23

RSS订阅

Open Toolbar