![](/img/trans.png)
[英]How to get combination of Nth line(specific line) and last but one line from text file in Linux?
[英]How to read data in text file from nth line to last
我在 Linux 中有一个包含多行的 .txt 文件。
前任:-
第 1 行 第 2 行 第 3 行 第 4 行 第 5 行 第 6 行
我想从第 4 行读取数据以结束文件并需要复制到 separte.txt 文件。
数据在单独的.txt 文件中应该是这样的。
第 4 行 第 5 行 第 6 行
使用 sed:
sed -n '4,$p' file.txt > other.txt
使用 awk:
awk 'NR>=4' file.txt > other.txt
这也应该有效:
tail --lines=+4 file.txt > otherfile.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.