Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键 批量修改文件名等
2014-05-23 09:11
555 查看
http://blog.sina.com.cn/s/blog_62e7fe670101dg9d.html
linux下二进制文件查找:
strings 0000.ts | grep -o "T" | wc -l
grep _initcall_.*1$ ./aa > a1
批量修改文件名
rename 's/\.pkt/\.aac/' *
http://any2sky.blog.163.com/blog/static/468518032010914101851175/
将通过find命令找到的文件拷贝到一个新的目录中:
cp `find . -name "*pcm*.[c,h]"` tmp/ -rf
方法一 www.2cto.com
命令如下:
find src_dir -name "access.log.2011102[2-6]*" -exec cp {} dst_dir \;
拷贝文件到远程主机上的目标目录的命令:
find src_dir -name "access.log.2011102[2-6]*" -exec scp {} 用户名@主机ip:dst_dir \;
方法二
find src_dir -name "access.log.2011102[2-6]*" |xargs -i cp {} dst_dir
或
find src_dir -name "access.log.2011102[2-6]*" |xargs -I {} cp {} dst_dir
拷贝文件到远程主机上的目标目录的命令:
find src_dir -name "access.log.2011102[2-6]*" |xargs -i scp {} 用户名@主机ip:dst_dir
或
find src_dir -name "access.log.2011102[2-6]*" |xargs -I {} scp {} 用户名@主机ip:dst_dir
src_dir 源目录
dst_dir 目标目录
access.log.2011102[2-6]* 文件名的正则表达式,获取文件的条件
Linux下find一次查找多个指定文件或者排除某类文件,在 GREP 中匹配多个关键字的方法
(1)Linux下find一次查找多个指定文件:
查找a.html和b.html
find . -name "a.html" -name "b.html"
find . -regex '.*\.txt\|.*\.doc\|.*\.mp3'
find . -regex '.*\.txt\|.*\.doc\|.*\.mp3'
./a.txt
./a.doc
./a.mp3
(2)排除某些文件类型:
排除目录下所有以html结尾的文件:
find . -type f ! -name "*.html"
find . -type f ! -name "*.html"
./ge.bak.02.09
./ge.html.changed.by.jack
./a.txt
./a.doc
./a.mp3
(3)排除多种文件类型的示例:
find . -type f ! -name "*.html" -type f ! -name "*.php" -type f ! -name "*.svn-base" -type f ! -name "*.js" -type f ! -name "*.gif" -type f ! -name "*.png" -type f ! -name "*.cpp" -type f ! -name "*.h" -type f ! -name "*.o" -type f ! -name "*.jpg" -type f ! -name "*.so" -type f ! -name "*.bak" -type f ! -name "*.log"
(3)在 GREP 中匹配多个关键字的方法:
grep查找多个数字的文件:
-r
递归,-E:正则 -l:只显示文件名
root@116.255.139.240:~/a# grep -r -E '0341028|100081|10086|10001' *
a.txt:100081
b.txt:10086
c/cc.txt:0341028
c/cc.txt:100081
c/cc.txt:10086
c/cc.txt:10001
c.txt:10001
d.txt:0341028
grep -r -E -l '0341028|100081|10086|10001' *
a.txt
b.txt
c/cc.txt
c.txt
d.txt
多种类型文件示例:
view plainprint?
find . -name "*.html" -o -name "*.js"|xargs grep -r "BusiTree"
用Awk:
view plainprint?
find . -name "*.php"|awk '{print "cat " $0 " |grep -H dbsys.mxxxx.justwinit.cn"}'|sh
linux下二进制文件查找:
strings 0000.ts | grep -o "T" | wc -l
grep _initcall_.*1$ ./aa > a1
批量修改文件名
rename 's/\.pkt/\.aac/' *
http://any2sky.blog.163.com/blog/static/468518032010914101851175/
将通过find命令找到的文件拷贝到一个新的目录中:
cp `find . -name "*pcm*.[c,h]"` tmp/ -rf
方法一 www.2cto.com
命令如下:
find src_dir -name "access.log.2011102[2-6]*" -exec cp {} dst_dir \;
拷贝文件到远程主机上的目标目录的命令:
find src_dir -name "access.log.2011102[2-6]*" -exec scp {} 用户名@主机ip:dst_dir \;
方法二
find src_dir -name "access.log.2011102[2-6]*" |xargs -i cp {} dst_dir
或
find src_dir -name "access.log.2011102[2-6]*" |xargs -I {} cp {} dst_dir
拷贝文件到远程主机上的目标目录的命令:
find src_dir -name "access.log.2011102[2-6]*" |xargs -i scp {} 用户名@主机ip:dst_dir
或
find src_dir -name "access.log.2011102[2-6]*" |xargs -I {} scp {} 用户名@主机ip:dst_dir
src_dir 源目录
dst_dir 目标目录
access.log.2011102[2-6]* 文件名的正则表达式,获取文件的条件
Linux下find一次查找多个指定文件或者排除某类文件,在 GREP 中匹配多个关键字的方法
(1)Linux下find一次查找多个指定文件:
查找a.html和b.html
find . -name "a.html" -name "b.html"
find . -regex '.*\.txt\|.*\.doc\|.*\.mp3'
find . -regex '.*\.txt\|.*\.doc\|.*\.mp3'
./a.txt
./a.doc
./a.mp3
(2)排除某些文件类型:
排除目录下所有以html结尾的文件:
find . -type f ! -name "*.html"
find . -type f ! -name "*.html"
./ge.bak.02.09
./ge.html.changed.by.jack
./a.txt
./a.doc
./a.mp3
(3)排除多种文件类型的示例:
find . -type f ! -name "*.html" -type f ! -name "*.php" -type f ! -name "*.svn-base" -type f ! -name "*.js" -type f ! -name "*.gif" -type f ! -name "*.png" -type f ! -name "*.cpp" -type f ! -name "*.h" -type f ! -name "*.o" -type f ! -name "*.jpg" -type f ! -name "*.so" -type f ! -name "*.bak" -type f ! -name "*.log"
(3)在 GREP 中匹配多个关键字的方法:
grep查找多个数字的文件:
-r
递归,-E:正则 -l:只显示文件名
root@116.255.139.240:~/a# grep -r -E '0341028|100081|10086|10001' *
a.txt:100081
b.txt:10086
c/cc.txt:0341028
c/cc.txt:100081
c/cc.txt:10086
c/cc.txt:10001
c.txt:10001
d.txt:0341028
grep -r -E -l '0341028|100081|10086|10001' *
a.txt
b.txt
c/cc.txt
c.txt
d.txt
多种类型文件示例:
view plainprint?
find . -name "*.html" -o -name "*.js"|xargs grep -r "BusiTree"
用Awk:
view plainprint?
find . -name "*.php"|awk '{print "cat " $0 " |grep -H dbsys.mxxxx.justwinit.cn"}'|sh
相关文章推荐
- Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键
- Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键
- Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键
- Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件 *****
- Linux下find一次查找多个指定类型文件,指定文件或者排除某类文件,在 GREP 中匹配多个关键
- linux中find查找指定时间段的文件并grep查找内容
- Linux - find命令查找文件或者文件夹
- linux 下查找文件和字符串命令 find grep
- linux下的find文件查找命令与grep文件内容查找命令
- 用grep在子目录中指定的文件类型中查找
- grep在指定类型的文件中查找字符
- grep如何递归目录并在指定类型文件中查找
- linux查找命令、find、grep找到需要的文件
- linux查找命令、find、grep找到需要的文件
- [linux ]find命令是用正则匹配目录查找文件
- linux下的find文件查找命令与grep文件内容查找命令
- Linux 文件、内容查找(递归) ,grep ,find
- 用grep查找指定目录及其子目录下的特定文件类型
- grep在指定类型的文件中查找字符
- grep查找指定文件类型