如何以相反的顺序连接文件

1 terminal cat tac

我希望按照与列表中显示的顺序相反的顺序连接目录中的文件列表。

tac这与以tac相反的行顺序连接文件不同。

基本上我有一个包含 3 个文件的文件夹file1file2file3.

cat f* > newfile将像这样合并这些文件:

file1
file2
file3
Run Code Online (Sandbox Code Playgroud)

但是,我想像这样合并文件

file3
file2
file1
Run Code Online (Sandbox Code Playgroud)

同时保持正确的线路顺序。

Kam*_*ski 5

\n

tac这与以tac相反的行顺序连接文件不同

\n
\n

\xe2\x80\xa6 并且不在所需的文件逆序中。令人惊讶的是,这很好,因为tac对整个输出进行额外的操作将为您提供您想要的结果:

\n
tac f* | tac\n
Run Code Online (Sandbox Code Playgroud)\n