题解 | #打印文件的最后5行#

打印文件的最后5行

http://www.nowcoder.com/practice/ff6f36d357d24ce5a0eb817a0ef85ee2

!/bin/bash
tail -5 nowcoder.txt
#或
tail -n 5 nowcoder.txt

看到题目要求,就知道,使用tail和head就可以了

tail和head常用语法

tail 文件名 
# 默认显示文件后10行
tail -n 文件名
# 显示文件后n行head 文件名 默认显示文件前10行
head -n 文件名
# 显示文件前n行 
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 17:10
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务