从“ cat line x 到 line y on a large file ”的一个小问题:
我有一个巨大的文件(2-3 GB)。我只想从具有“foo:”的行到具有“goo:”的行进行猫/打印。假设“foo:”和“goo:”在一个文件中只出现一次;"foo:" 继续 "goo:"。
到目前为止,这是我的方法:
grep -nr "foo:" bigfile123456: foo: hello world!和654321: goo: good bye!tail -n+123456 bigfile | head -n 530865我的问题是如何用表达式(例如,grep ...)有效地替换行号常量?
我可以编写一个简单的 Python 脚本,但只想使用组合命令来实现它。