如何反转文件中行的顺序? [英] How can I reverse the order of lines in a file?
本文介绍了如何反转文件中行的顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想颠倒文本文件(或stdin)中行的顺序,保留每行的内容。
I'd like to reverse the order of lines in a text file (or stdin), preserving the contents of each line.
因此,
foo
bar
baz
我想结束于
baz
bar
foo
有没有标准的UNIX命令行实用程序?
Is there a standard UNIX commandline utility for this?
推荐答案
BSD尾:
tail -r myfile.txt
参考: FreeBSD , NetBSD , OpenBSD 和 OS X 手册页。
这篇关于如何反转文件中行的顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文