2013-07-09 18 views

cevap

2

Kullandığınız işletim sisteminden bahsetmediniz, ancak linux gibi bir "sarmalayıcı" komut dosyası yazabilirsiniz. git-grep1 gibi bir kabuk adlı bir komut dosyası oluşturun ve $ PATH'nizde bulunan bir dizine koyun, böylece onu bulabilirsin. Sonra komut dosyanızın yerleşik bir git komutuymış gibi git grep1 param1 param2... yazabilirsiniz. Muhtemelen belki tarafından genişlemesini önlemek için $file_spec ve tek tırnak içinde her desen içine alarak, örneğin, bu deneme yapmak gerekir

# Example use: find C source files that contain "pattern" or "pat*rn" 
# $ git grep1 '*.c' pattern 'pat*rn' 

# Ensure we have at least 2 params: a file name and a pattern. 
[ -n "$2" ] || { echo "usage: $0 FILE_SPEC PATTERN..." >&2; exit 1; } 

file_spec="$1" # First argument is the file spec. 
shift 
pattern="-e $1" # Next argument is the first pattern. 
shift 

# Append all remaining patterns, separating them with '--and'. 
while [ -n "$1" ]; do 
    pattern="$pattern --and -e $1" 
    shift 
done 

# Find the patterns in the files. 
git grep -i "$pattern" -- "$file_spec" 

: Burada

hızlı bir başlangıç ​​için örnek kabuk.

0

dizelerin göreli düzeni biliyorsanız, o zaman bir

git grep str1.*str2.*str3 -- *strings*txt 
İlgili konular