代码之家  ›  专栏  ›  技术社区  ›  shantanuo

仅选择属于冒号的单词

  •  0
  • shantanuo  · 技术社区  · 4 年前

    我有一个使用标记语言的文本文件(类似于维基百科文章)

    cat test.txt
    This is a sample text having: colon in the text. and there is more [[in single or double: brackets]]. I need to select the first word only.
    and second line with no [brackets] colon in it.
    

    我需要选择单词“having:”仅仅因为这是常规文本的一部分。我试过了

    grep -v '[*:*]' test.txt
    

    这将正确避免标记,但不会选择预期的单词。

    0 回复  |  直到 4 年前