【发布时间】:2021-02-20 09:58:11
【问题描述】:
我需要解析 mdimport(macOS 中的 Spotlight 相关工具)的输出
mdimport -t -d3 $file
...将许多属性和值转储到标准输出,包括 kMDItemTextContent。
如何使用 grep/awk/sed/等。只留下 kMDItemTextContent 的值?
您可以使用 mdimport -t -d3 我的文件之一的部分输出作为示例。
kMDItemPageHeight = 842;
kMDItemPageWidth = 595;
kMDItemPhysicalSize = 12288;
kMDItemSecurityMethod = None;
kMDItemTextContent = "11/8 - Hash Tag Test Document #HashTag1 this is the first hash tag. #HashTag2 this is the second hash tag. The following hash tag is inside and at the end of a paragraph: #HashTag3 The next hash tag #HashTag4 is in the middle of a paragraph.";
kMDItemTitle = "11/8 - Hash Tag Test Document";
kMDItemVersion = "1.3";
}
注意 - 我在某些文件的文本块中看到了明确的 \n\n 字符。
我想,我更具体的问题是,如何获取这两个分隔符之间的所有文本?
kMDItemTextContent = "
与
";
【问题讨论】: