Filter column with awk and regexp

前端 未结 6 954
谎友^
谎友^ 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:48

    The way to write the script you posted:

    awk '{ if($6 == '/[1-100][S|M][1-100][S|M]/') print} file.txt
    

    in awk so it will do what you SEEM to be trying to do is:

    awk '$6 ~ /^(([1-9][0-9]?|100)[SM]){2}$/' file.txt
    

    Post some sample input and expected output to help us help you more.

提交回复
热议问题