作者:mobiledu2502931077 | 来源:互联网 | 2023-02-03 15:40
1> Mad Physicis..:
tail
接受行计数作为-n ...
或--lines=...
标志的一部分。从联机帮助页:
-n, --lines=[+]NUM
output the last NUM lines, instead of the last 10; or use -n
+NUM to output starting with line NUM
替换tail +$1 $3
为tail -n +$1 $3
或tail --lines=+$1 $3
。
有趣的是,您已经在使用对的正确标志head
。
关于服务器故障,还有一个非常相似的问题:https : //serverfault.com/questions/133692/how-to-display-certain-lines-from-a-text-file-in-linux。普遍的共识是您的方法很好,但是另一种选择是script.sh
使用sed
诸如
#!/bin/bash
sed -n "${1},${2}p" ${3}
@DeepakSingh。如果这对您有用,请选择答案。我注意到您有不这样做的习惯。