简体   繁体   中英

How to get combination of Nth line(specific line) and last but one line from text file in Linux?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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