如何仅 grep Mac 中以特定单词开头的行?

how to grep only lines that start with specific word in Mac?

我有一个文本文件。

我想用特定的词`"length="

grep 开始的所有行

我可以使用 sublime 在终端的哪一行 运行 只获取这些行?

正文:

   }, {
      "path" : "{\"segmentId\":22439323,\"nodeId\":18437268,\"x\":-71.205646,\"y\":42.38619}",
      "distance" : 2744,
      "length" : 73,
      "instruction" : {
        "opcode" : "CONTINUE"
      },
      "crossTime" : 5,
      "additionalInstruction" : null,
      "detourSavings" : 0,
      "isToll" : false,
      "knownDirection" : true
    }, {
      "path" : "{\"segmentId\":67031059,\"nodeId\":18404240,\"x\":-71.206302,\"y\":42.38574800000001}",
      "distance" : 2749,
      "length" : 9,
      "instruction" : {
        "opcode" : "CONTINUE"
      },
      "crossTime" : 1,
      "additionalInstruction" : null,
      "detourSavings" : 0,
      "isToll" : false,
      "knownDirection" : true
    }, {

假设您需要找到带有 "length" : 的行,这就完成了工作:

 grep '^\s*"length" :' yourfile