Filter column with awk and regexp

前端 未结 6 1081
谎友^
谎友^ 2021-02-01 19:08

I\'ve a pretty simple question. I\'ve a file containing several columns and I want to filter them using awk.

So the column of interest is the 6th column and I want to fi

6条回答
  •  不思量自难忘°
    2021-02-01 19:59

    Regexes cannot check for numeric values. "A number from 1 to 100" is outside what regexes can do. What you can do is check for "1-3 digits."

    You want something like this

    /\d{1,3}[SM]\d{1,3}[SM]/
    

    Note that the character class [SM] doesn't have the ! alternation character. You would only need that if you were writing it as (S|M).

提交回复
热议问题