繁体   English   中英

如何根据给定的模式将linux中的文本文件从文件底部拆分到顶部

[英]How to split a text file in linux from the bottom of the file to the top based on a given pattern

如何根据给定的模式在Linux中将文本文件从文件底部拆分到顶部(无论使用什么命令都无所谓)。

如果我有文件:

111
aaa
222
aaa
333
aaa

输出应为

1st file
    333
    aaa

2nd file
    222
    aaa

3rd file
    111
    aaa

谢谢。

tac反转文件,然后通过csplit运行它。 -k选项意味着您不需要预先知道分割数。

tac文件| csplit -s -k-“ / aaa / + 1”“ {99}”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM