difference between grep Vs cat and grep

后端 未结 5 992
再見小時候
再見小時候 2020-12-29 05:53

i would like to know difference between below 2 commands, I understand that 2) should be use but i want to know the exact sequence that happens in 1) and 2) suppose filename

5条回答
  •  春和景丽
    2020-12-29 06:40

    Actually, though the outputs are the same;

    -$cat filename | grep regex
    

    This command looks for the content of the file "filename", then fetches regex in it; while

    -$grep regex filename
    

    This command directly searches for the content named regex in the file "filename"

提交回复
热议问题