计算linux中制表符的数量

rav*_*avi 5 unix bash grep csh

我想hard tab characters在unix shell中计算我文档中的数字.

我该怎么做?

我试过类似的东西

grep -c \t foo

但它在文件foo中给出了t的计数.

Wil*_*ell 13

使用tr丢弃除标签之外的所有内容,然后计数:

< input-file tr -dc \\t | wc -c
Run Code Online (Sandbox Code Playgroud)


che*_*ner 8

Bash使用$'...'表示法来指定特殊字符:

grep -c $'\t' foo
Run Code Online (Sandbox Code Playgroud)