简体   繁体   English

linux上的grep命令(尤其是grep --exclude)

[英]grep command on linux ( especially grep --exclude)

I'm newbie on linux issues and before asking here I googled it however I couldnt find a clue about grep --exclude.So I wonder what does the line below ?? 我是Linux问题的新手,在问这之前我先用谷歌搜索过它,但是我找不到关于grep --exclude的线索。所以我想知道下面的代码是什么? Thanks in advance 提前致谢

grep --exclude=\*.svn\* -r REVISION 1.0.0.8/*1.0.0.8.config > 1.0.0.8-REVISION.txt

SOLVED BY MYSELF 由MYSELF解决

search REVISION on "1.0.0.8/*1.0.0.8.config" file exluding .svn file and send output to 1.0.0.8-Revision.txt 在排除.svn文件的“ 1.0.0.8/*1.0.0.8.config”文件上搜索REVISION并将输出发送到1.0.0.8-Revision.txt

To grep through a directory while excluding various file types (in your example anything prefixed with .svn ) you probably want to do the following: 要在目录中grep排除各种文件类型(在您的示例中以.svn开头的文件),您可能需要执行以下操作:

grep -r "SOMETHING" --exclude="*.svn*" /path/to/directory >  1.0.0.8-REVISION.txt 2>&1

This will grep through all files within a directory recursively, then post the matches to a file called 1.0.0.8-REVISION.txt which is located relative to where you are currently searching. 这将递归遍历目录中的所有文件,然后将匹配项发布到名为1.0.0.8-REVISION.txt的文件中,该文件相对于当前搜索的位置而定位。

If you provide more information abut exactly what you're trying to grep/find I can update my answer with something that will work exactly for your case. 如果您提供的更多信息恰好是您要尝试grep / find的信息,那么我可以使用适合您的情况的某些信息来更新我的答案。

you can find grep on man pages here . 你可以找到grep的手册页这里

what exclude does: 排除功能:

--exclude=PATTERN: --exclude = PATTERN:

  • Recurse in directories skip file matching PATTERN. 目录中的递归会跳过与PATTERN匹配的文件。

your command will search, recursively, in all directories, skipping file pattern "*.svn*" and searching for file pattern "1.0.0.8/*1.0.0.8.config > 1.0.0.8-REVISION.txt" 您的命令将在所有目录中递归搜索,跳过文件模式“ * .svn *”,然后搜索文件模式“ 1.0.0.8/*1.0.0.8.config> 1.0.0.8-REVISION.txt”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM