如何使用一些临时命令打印文件内容以及 linux 中的文件名

How to print contents of file as well as filename in linux using some adhoc command

我有多个以 DUMP_* 开头的文件。
每个文件都有特定转储的数据。
我想在 stdout

中打印文件名和文件内容

预期的输出应该是

FILENAME
ALL CONTENTS OF FILE
and so on

我试过的最接近的是

cat $(ll DUMP_* | awk -F ' ' '{print }' ) | less 

有了这个我无法弄清楚哪些内容属于哪个文件。 另外,我不愿意使用 shell 脚本,最好使用临时命令。

这个答案并不完全符合你的期望,但是你看到文件名和它的内容之间的 link 更好:

情况:

Prompt>cat DUMP_1
Info
More Info
Prompt>cat DUMP_2
Info

解决方案:

Prompt>grep "" DUMP_*
DUMP_1:Info
DUMP_1:More Info
DUMP_2:Info