0 30even m"og:type" content="webpage">030even m" /> 030even m"> Linux如何使用cat命令显示隐藏字符_系统运维_内存溢出

阅读 19

Linux如何使用cat命令显示隐藏字符,第1张

首先,我们创建一个简单的文本文件,写入一些特殊字符。打开终端,运行

命令

printf ‘testing\012\011\011testing\014\010\012more testing\012\011\000\013\000even more testing\012\011\011\011\012’ 》 /tmp/testing.txt现在用不同的编辑器软件打开,

显示

的结果会不同。用简单的cat打开将显示:

$ cat /tmp/testing.txt

testing

testing

more testing

even more testing

如果用nano或者vim打开,将会看到:

testing

testing^L^H

more testing

^@^K^@even more testing

现在我们给cat加上一些选项参数,以便能显示出特殊字符来。

用cat -T命令来显示TAB键的字符^I

cat -T /tmp/testing.txt

testing

^I^Itesting

more testing

^I

even more testing

^I^I^I

用cat -E命令来显示行尾的结束字符$

$ cat -E /tmp/testing.txt

testing$

testing

$

more testing$

even more testing$

$

用简单的cat -A命令就可以显示所有不可见的字符:

$ cat -A /tmp/testing.txt

testing$

^I^Itesting^L^H$

more testing$

^I^@^K^@even more testing$

^I^I^I$

上面就是Linux使用cat命令显示隐藏字符的方法介绍了,cat命令除了能够显示不可见字符外,还有其他的功能,具体的可以参考系统之家Linux下如何使用cat命令?

文件,如果是文本格式的,不可见字符始终是不可见的。。。不可见字符有\n, \t, 等,可以参考http://zhidao.baidu.com/question/21146309.html

如果是想查看当前目录下的所有文件(包括隐藏文件),可以用 ls -a

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

int main(void)

{

char s[80] = ""

flockfile(stdin)

printf("sleeping...\n")

sleep(5)

printf("please input something.\n")

fgets_unlocked(s, 80, stdin)

gets(s)

printf("you input is [ %s ].\n", s)

return 0


}

上面的程序我已经测试了,完全符合你的要求,用的方法是阻断当前用户输入,解锁后恢复输入的方法,在阻断区间用户输入被过滤掉

欢迎分享,转载请注明来源:内存溢出

原文地址:
https://outofmemory.cn/yw/8900102.html打开
阻断
(0) 微信扫一扫 打赏 支付宝扫一扫 微信扫一扫
支付宝扫一扫
先锋人物 先锋人物
Linux Windows远程连接工具的使用SSH(Windows和Linux之间相互传递文件)
上一篇
2023-04-22
如何查看linux并发连接数?
2023-04-22

发表评论 后才能评论
提交

评论列表(0条)

2022-4-12

沙钢
游勇
保存{label} {label} {label} {label}