Grep match only before “:”

前端 未结 3 1617

Hello How can I grep only match before : mark?

If I run grep test1 file, it shows all three lines.

test1:x:29688:test1,test2
te         


        
3条回答
  •  渐次进展
    2021-01-26 17:30

    I think that you just need to add “:” after “test1”, see an example:

    grep “test1:” file
    

提交回复
热议问题