如何 grep tab & 如何grep 減號(dash)

grep tab有以下3種方式: shell

grep -P "\t"

awk '/1915848\t/'

ctr+c 複製 一個. 

 

"-"在shell中是option的前綴符號. 即使被放入單引號中, 也會提示報錯spa

$ cat t.dat | grep '----'
grep: unrecognized option `----'
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.

 

簡單方法: cmd -- '---'code

$ cat t.dat | grep -- '---'
--------1
--------2
--------a

 

grep 自身支持 -e 選項, 所以grep 減號, 有以下幾種方法: orm

$ cat t.dat
--------1
--------2
--------a

$ cat t.dat | grep -e '--------[0-9]'
--------1
--------2
$ cat t.dat | grep -- '--------[0-9]'
--------1
--------2
相關文章
相關標籤/搜索