英文:
How to get combination of Nth line(specific line) and last but one line from text file in Linux?
问题
我需要从文件中获取第17行和倒数第二行,并将它们合并成文件中的第99行。
英文:
In a file, I have 100 lines. But I want 17th and last but one as 99th line from the file.
I need the command combinedly.
答案1
得分: 1
获取第17行:
head -17 file | tail -1
获取第99行:
tail -2 file | head -1
用分号组合这些命令:
head -17 file | tail -1 ; tail -2 file | head -1
英文:
Get the 17th line:
head -17 file | tail -1
Get the 99th line:
tail -2 file | head -1
Combine the commands with a semicolon:
head -17 file | tail -1 ; tail -2 file | head -1
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论