Unix搜索,排除和解析

问题描述:

我有一个需要帮助的用例。Unix搜索,排除和解析

以下是我的文件夹结构:

/home/stage/m1/folder1/att.json 
/home/stage/m1/folder1test/att.json 
/home/stage/m1/folder2/att.json 
/home/stage/m1/folder2test/att.json 
/home/stage/m1/folder3/att.json 
/home/stage/m1/folder3test/att.json 

JSON文件有几个属性。其中之一是这样的:

{ 
"name" : "customes", 
"value" : "Y" 
} 

我想通过所有文件夹查找/除内部“测试”文件夹中的文件,文件,列出上述的名字和上面提到的JSON属性的值。

所以输出应该是名称和“customes”属性的值从任何帮助将高度赞赏的文件夹

/home/stage/m1/folder1/att.json 
/home/stage/m1/folder2/att.json 
/home/stage/m1/folder3/att.json 

问候

+1

为什么这个标签'unix'?在关于unix的问题中看到以'D:'开头的完整路径名是很奇怪的。 –

您可以使用grep排除dir选项

grep -ril --exclude-dir="*test" "customes" ./ 

或者

grep -ril "customes" ./ | grep -v "*test" 
+0

谢谢。我也想打印“价值”。这怎么可以做到这一点? – Tarun

+0

你的意思是json的价值? – chakri

+0

是json中的值 – Tarun