### [筆記] 利用find/grep/xargs 在目錄中找出所有包含特定字串的檔案路徑

2013-11-14 工作筆記

很好用的指令

在當前目錄底下(包含子目錄)尋找所有附檔名為php的檔案，並在這些檔案中，尋找包含 abc.def 字串的檔案並列出結果

> find .. -name “.php”|xargs grep -n abc.def 使用結果 > [root@vm00015-1 models]# find .. -name “.php”|xargs grep -n abc.def > > ../views/welcome.php:252: <span><a href=“http://abc.def.com" target=”_blank”>設計</a></span> > > ../views/welcome.php:260: <span><a href=“http://abc.def.com" target=”_blank”></a></span> > > ../views/welcome.php:263: <span><a href=“http://abc.def.com" target=”_blank”></a></span> > > ../views/mobile.php:127: <span><a href=“http://abc.def.com" target=”_blank”>設計</a></span> > > ../views/mobile.php:130: <span><a href=“http://abc.def.com" target=”_blank”></a></span> > > ../views/mobile.php:133: <span><a href=“http://abc.def.com" target=”_blank”></a></span> > > ../views/template.php:165: <span><a href=“http://abc.def.com" target=”_blank”>設計</a></span> > > ../views/template.php:168: <span><a href=“http://abc.def.com" target=”_blank”></a></span> > > ../views/template.php:171: <span><a href=“http://abc.def.com" target=”_blank”></a></span> > > ../views/admin/panel.php:81: <a href = “http://abc.def.com" target=”_blank”> > > ../views/admin/login.php:81: <a href = “http://abc.def.com" target=”_blank”> > > ../views/contact/locations.php:74: icon: “http://abc.def.com/img/flag.png" > > [root@vm00015-1 models]# > > >

comments powered by Disqus
© 2017 by Lednerb
Bilberry Hugo Theme