English 中文(简体)
自动忽略灰色中的档案
原标题:Automatically ignore files in grep
  • 时间:2009-12-12 04:29:53
  •  标签:
  • grep
  • bash

在寻找某种东西时,我是否可使用灰色来忽略某些档案,这种东西相当于ore或ign。 在寻找源码时,我通常使用这样的东西。

grep -r something * | grep -v ignore_file1 | grep -v ignore_file2

即便我能为忽视这些档案而设一个包子,也是有益的。

最佳回答

http://www.un.org/Depts/DGACM/index_spanish.htm

grep  perl * --exclude=try* --exclude=tk*

现行目录中的每1份档案的搜索,其中不包括从<条码>开始的文档。

问题回答

您也不妨对ack进行查询,除许多其他特征外,还不搜寻像svn和.git这样的安全局名录。

find . -path ./ignore -prune -o -exec grep -r something {} ;

在你目前名录中发现的所有档案都排除了称为“敌方”的目录(或档案),然后执行指挥圈——在不公的档案中发现的每个档案中都有的东西。

扩大使用

shopt -s extglob
for file in !(file1_ignore|file2_ignore) 
do
  grep ..... "$file"
done

I thinks grep does not have filename filtering. To accomplish what you are trying to do, you can combine find, xargs, and grep commands. My memory is not good, so the example might not work:

find -name "foo" | xargs grep "pattern"

Find is flexible, you can use wildcards, ignore case, or use regular expressions. You may want to read manual pages for full description.

在阅读下一个职位后,表面看来灰色确实有档案过滤器。

这里使用的是微乎其微。 • 要求标准使用量:awk, sed(由于我的腹部如此大)

cat > ~/bin/grepignore  #or anywhere you like in your $PATH
egrep -v "`awk  1  ORS=| .grepignore | sed -e  s/|$//g  ; echo`"
^D
chmod 755 ~/bin/grepignore
cat >> ./.grepignore  #above set to look in cwd
ignorefile_1
...
^D
grep -r something * | grepignore

www.un.org/Depts/DGACM/index_spanish.htm 1. 拟订一个简单的更改条款:

egrep -v ignorefile_one|ignorefile_two

a. 并非有可观的效率,而是手工使用的良好条件





相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...

热门标签