how to use grep to match with either whitespace or newline

前端 未结 3 578
孤街浪徒
孤街浪徒 2021-01-07 20:18

I want to grep a file with a word, say \"AAA\", and it ends with whitespace or newlines. I know how to write this seperately, as follows, but having problems in combining th

3条回答
  •  孤街浪徒
    2021-01-07 20:53

    If you are looking for word AAA followed by space anywhere in the string, or at the end of line, then use

    grep -P "AAA( |$)"
    

提交回复
热议问题