leetcode with Bash:195. Tenth Line

题目:

Given a text file file.txt, print just the 10th line of the file.

给定一个txt档,印出里面的第十行

这......其实就在考我们认不认识awk或sed吧

sed:

sed -n "10p" file.txt

-n表唯读,但遇到p指令所以印出第十行
最后执行时间35ms(faster than 89.27%)

awk:

awk 'NR==10' file.txt

NR表第几组资料,我们要第10行所以==10
最后执行时间32ms(faster than 94.25%)

那我们下题见


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章