从下到上查看文件
您好,
我知道 cat
在屏幕上打印文件的内容。
我从来没有在linux上工作过。但是我知道tac
是从下到上显示文件的命令。我什至不确定tac是否在unix上。至少在我的unix盒子上它不存在。 我想知道是否有一个简单的 unix 命令可以从下到上给出输出?
我期待如下:
<command> file_name;
我知道这可以使用 awk、sed 等工具来完成。 但有人可以告诉我一个最简单的命令来执行该任务吗?
HI,
I know that cat
prints the contents of the file on screen.
i never worked on linux.But i am aware that tac
is the command to show the file from bottom to top.I am not even sure whether tac is on unix.Atleast on my unix box its not present.
i want to know is there a simple command unix which gives the output from bottom to top?
i am expecting like below :
<command> file_name;
I know this can be done using some tools like awk
,sed
.
but could anyone please tell me a most simple command to perform that task?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Unix 上的等价物
是
希望这会有所帮助
The Unix equivalent of
is
Hope this helps
tac :Tac 与 cat 相反,它产生的输出以先显示最后一行,然后显示倒数第二行的方式呈现在。
https://www.howtoforge.com/linux-tac-command/
tac : Tac is opposite to cat in the sense that the output it produces is presented in a way that the last line is displayed first, then the second last line, and so on.
https://www.howtoforge.com/linux-tac-command/
您可以使用 tail -r
这可能应该移至 unix.stackexchange.com
You can use tail -r
This probably should be moved to unix.stackexchange.com
tac
位于 GNU coreutils 中,并且是目前唯一可以执行您想要的操作的单个文件可执行文件。如果您没有安装 tac,则需要使用速度较慢的替代方案,例如 如何反转文本文件的行?tac
is in GNU coreutils, and is presently the only single file executable that does what you want. If you don't havetac
installed you'll need to use a slower alternative, like the ones outlined at How to reverse lines of a text file?