About 'grep -f': match pattern with file

前端 未结 2 746
醉酒成梦
醉酒成梦 2021-02-15 13:26

I am using the grep -f function to extract lines from a file which match a particular pattern. Let\'s say my pattern file is pattern.txt, as follows.

2条回答
  •  失恋的感觉
    2021-02-15 13:53

    Add ^ before your patterns so that grep will match a line start with your pattern. If your pattern is actually set of numbers, You don't need a list of patterns. Just use ^[1-5]:.

提交回复
热议问题