reverse lines in a text file

profesor / 2025-02-18 / 原文

 

change file from 

foo

bar

baz

to

baz

bar

foo

 

Linux:

tac file.txt

 

BSD:

tail -r file.txt

 

参考:https://stackoverflow.com/questions/742466/how-can-i-reverse-the-order-of-lines-in-a-file