【问题标题】:How to grep lines with specific words, starting either with multiple spaces or tabs?如何以多个空格或制表符开头的特定单词 grep 行?
【发布时间】:2016-07-07 08:02:13
【问题描述】:

这些是可能的用例,来自文件的不同行示例。这些行将只包含一个 checkWord。

> checkWord
>     checkWord
>    checkWord
> <tab>   <tab> checkWord
> <tab>checkWord
> checkWord<tab>

how to grep all such cases?

【问题讨论】:

    标签: regex grep solaris ksh


    【解决方案1】:

    你可以grep使用:

    grep '^[[:blank:]]*checkWord'
    

    ^[[:blank:]]* 匹配行首的 0 个或多个空格或制表符。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-20
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多