如何在命令行空格可见 [英] How to make whitespaces visible in the command line
本文介绍了如何在命令行空格可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个非常大的文件,其中我想用头
来检查的前100行:
I have a very large file, of which I want to inspect the first 100 lines using head
:
head -n100 large.file
我真的很想做空格LIK \\ t
\\ r
,...可见。我怎样才能做到这一点。我没有找到男人头的选项
。
I'd really like to make whitespaces lik \t
\r
,... visible. How can I do this. I did not find an option in man head
.
推荐答案
您可以用Perl做
echo 'fooo bar' | perl -pe 's/( +)/\033[41m$1\033[00m/g'
\\ 033 [41米
使红色和 \\ 033 [00米
禁用它。 Perl,以 -pe
作品像 SED
键,只需要把周围空间的特殊序列。
\033[41m
enables red color and \033[00m
disables it. Perl with -pe
works like sed
and is needed only to put those special sequences around spaces.
要突出换行符的常规前pression的第一部分改为
To highlight line breaks change the first part of the regular expression to
s/([ \n]+)/...rest of the expression
这篇关于如何在命令行空格可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文