我希望按照与列表中显示的顺序相反的顺序连接目录中的文件列表。
tac这与以tac相反的行顺序连接文件不同。
基本上我有一个包含 3 个文件的文件夹file1,file2和file3.
cat f* > newfile将像这样合并这些文件:
file1
file2
file3
Run Code Online (Sandbox Code Playgroud)
但是,我想像这样合并文件
file3
file2
file1
Run Code Online (Sandbox Code Playgroud)
同时保持正确的线路顺序。
\n\n\n
tac这与以tac相反的行顺序连接文件不同
\xe2\x80\xa6 并且不在所需的文件逆序中。令人惊讶的是,这很好,因为tac对整个输出进行额外的操作将为您提供您想要的结果:
tac f* | tac\nRun Code Online (Sandbox Code Playgroud)\n