服务器find寻找文件路径,Linux find 查找文件
在日志文件夾下判斷是否有web服務器的日志文件夾,寫了個腳本:web
#!/bin/bash
cd /wls/annuity_acc
for sys in `cat ./WIIServer_name_list.txt`
do
#find /logs/$sys* -name "$sys*" |xargs echo -en '\n' >> 123.txt正則表達式
find /logs/$sys* -name "$sys*" -print
donebash
#find /logs/$sys* -name "$sys*" |xargs echo -en '\n' >> 123.txt 服務器
輸出到123.txt,可是若是有多個匹配的狀況會出現不換行的狀況,如:ui
ABBSWII6758??ABBSWII6759??ABBSWII6760spa
annWII3454日志
gbsWII9876
想要如下格式輸出到文本:web服務器
ABBSWII6758??it
ABBSWII6759?test
ABBSWII6760
annWII3454
gbsWII9876
只想到用-print方法
===============mark?? 2012-05-04=============
#find /logs/$sys* -name "$sys*" -exec ls -l?{} \;?>> 123.txt
能夠獲得列表效果
=============find -perm查找? 多路徑=============
這兩天碰到一個查找某一路徑下的非777的mdl文件,能夠用如下來實現:
find /pamis/data5/cognos/createcubes8/*/mdl -name "*.mdl" -type f |xargs ls -l |grep -v rwx
find /pamis/data5/cognos/createcubes8/*/mdl -name "*.mdl" -type f ! -perm 777 -exec ls -l {} \;
以上兩種獲得的效果是同樣的,可是若是要將獲得的結果作為輸入流傳給&2,可能二者會有差異
find后面的路徑支持多個,可是要以空格隔開,而且路徑支持*?[1-9]這樣的正則表達式:以下:
find /pamis/data5/cognos/createcubes8/*/mdl/[e,g,i,n,p][h,b,o,e][i,s,c,w,t,n]* -name "*.mdl" -type f ! -perm 777 -exec ls -l {} \; >&2
=========find -regex正則表達式查找? 多路徑===========
find /home/panzhaobo -name "*.pl" -type f ! -perm 777 -exec ls -l {} \;|xargs echo "" > testmdl.log
find -regex '/home/panzhaobo/.*\.pl' -type f ! -perm 777 -exec ls -l {} \;
上面的-regex是正則表達式后面的參數是帶全路徑的name
總結
以上是生活随笔為你收集整理的服务器find寻找文件路径,Linux find 查找文件的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: dell服务器sd卡装系统,DELL服务
- 下一篇: 无风扇网站服务器,这款服务器采用无风扇设
