如何在子文件夹中递归地在一个文件的不同行中复制两个模式?

时间:2019-01-31 11:01:22

标签: grep

if (value('X001_03') == 1) {  
    question('VAR', array(1));
} elseif(value('X001_03') == 2) {
    question('VAR', array(1,2));
} elseif(value('X001_03') == 3) {
    question('VAR', array(1,2,3));
} elseif(value('X001_03') == 4) {
    question('VAR', array(1,2,3,4));
} elseif(value('X001_03') == 5) {
    question('VAR', array(1,2,3,4,5));
} elseif(value('X001_03') == 6) {
    question('VAR', array(1,2,3,4,5,6));
} elseif(value('X001_03') == 7) {
    question('VAR', array(1,2,3,4,5,6,7));
} elseif(value('X001_03') == 8) {
    question('VAR', array(1,2,3,4,5,6,7,8))
}

请说明如何在所有子文件夹的文件中grep模式“ 3.100 ”和“ 3.99.5 ”,以获取匹配文件的列表:

./folder1/file1:3.100 ... 
./folder1/file1: 3.99.5

./folder1/file2:... 
./folder1/file2: 3.100

./folder1/file3:3.99.5 
./folder1/file3: ...

./folder2/file1:3.99.5 
./folder2/file1: ...

./folder2/file2:3.100 ... 
./folder2/file2: 3.99.5

./folder2/file3:...
./folder2/file3: 3.100

预先感谢!:)

1 个答案:

答案 0 :(得分:2)

Grep所有文件,仅打印匹配文件的名称,然后使用xargs grep重新扫描:

grep '3\.100' * -r -l  | xargs -d '\n' grep -l '3\.99\.5'