- 论坛徽章:
- 25
|
本帖最后由 wh7211 于 2022-06-14 16:11 编辑
- awk '/ID/{split(FILENAME,a,"[-/]");b=a[2]"-"a[3];c=gensub("[\",]","","g",$2);d[c]=d[c]?d[c]"\n"b" "c:b" "c}END{for(i in d){if(d[i]~"\n"){print d[i]}}}' storage-*/a.json
- 28-100 d8a18feb-ce42-4f4a-a14a-a0c5716a159d
- 28-110 d8a18feb-ce42-4f4a-a14a-a0c5716a159d
- 28-108 2fb6a047-a801-47ed-9990-8b376843a2cb
- 28-97 2fb6a047-a801-47ed-9990-8b376843a2cb
复制代码
- cat 1
- /storage-28-100/a.json
- /storage-28-110/a.json
- /storage-28-137/a.json
- /storage-28-143/a.json
- /storage-28-108/a.json
- /storage-28-97/a.json
- /storage-28-138/a.json
- /storage-28-158/a.json
- /storage-28-109/a.json
- /storage-28-142/a.json
- /storage-28-141/a.json
- /storage-28-136/a.json
- /storage-28-144/a.json
- cat 2
- {
- "ID": "d8a18feb-ce42-4f4a-a14a-a0c5716a159d",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true
- }{
- "ID": "d8a18feb-ce42-4f4a-a14a-a0c5716a159d",
- "Weight": 10,
- "CanSeal": false,
- "CanStore": true
- }{
- "ID": "5c752135-6037-442a-b9d1-cad111974e15",
- "Weight": 10,
- "CanSeal": false,
- "CanStore": true
- }{
- "ID": "08a241ab-ffa6-4795-8018-42d696d2cfbb",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true
- }{
- "ID": "2fb6a047-a801-47ed-9990-8b376843a2cb",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true,
- "MaxStorage": 0
- }{
- "ID": "2fb6a047-a801-47ed-9990-8b376843a2cb",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true,
- "MaxStorage": 0
- }{
- "ID": "a8b5352e-239e-4e7d-9b58-a4909b9120b1",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true,
- "MaxStorage": 0
- }{
- "ID": "62d71c03-55af-4367-8f1c-cf1301c4fa92",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true,
- "MaxStorage": 0
- }{
- "ID": "477c4f23-0dce-4717-a12d-027f8d4bbced",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true,
- "MaxStorage": 0
- }{
- "ID": "ea0b5a91-fcb5-40b0-85b6-1e2890c16e7d",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true,
- "MaxStorage": 0
- }{
- "ID": "f34644f9-c07e-4c48-9c8a-8b2145731273",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true,
- "MaxStorage": 0
- }{
- "ID": "5ee5d307-2635-436c-9323-d451745104af",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true,
- "MaxStorage": 0
- }{
- "ID": "c2a37ab5-110e-4329-ba25-bd1dfde9e441",
- "Weight": 10,
- "CanSeal": true,
- "CanStore": true
- }
- awk 'FILENAME==ARGV[1]{split($0,a,"[-/]");b[NR]=a[3]"-"a[4]}FILENAME==ARGV[2]&&/ID/{c++;d=gensub("[\",]","","g",$2);e[d]=e[d]?e[d]"\n"b[c]" "d:b[c]" "d}END{for(i in e){if(e[i]~/\n/){print e[i]}}}' 1 2
- 28-100 d8a18feb-ce42-4f4a-a14a-a0c5716a159d
- 28-110 d8a18feb-ce42-4f4a-a14a-a0c5716a159d
- 28-108 2fb6a047-a801-47ed-9990-8b376843a2cb
- 28-97 2fb6a047-a801-47ed-9990-8b376843a2cb
复制代码 |
|