Leetcode 195 Tenth Line
程序员文章站
2022-04-24 10:20:12
Given a text file file.txt, print just the 10th line of the file. Example: Assume that file.txt has the following content: Your script should output t ......
given a text file file.txt
, print just the 10th line of the file.
example:
assume that file.txt
has the following content:
line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8 line 9 line 10
your script should output the tenth line, which is:
line 10
note:
1. if the file contains less than 10 lines, what should you output?
2. there's at least three different solutions. try to explore all possibilities.
1. if the file contains less than 10 lines, what should you output?
2. there's at least three different solutions. try to explore all possibilities.
q.describe:use bash to print the tenth line of file.txt which is provide by the question setter.
solution:
awk 'nr == 10' file.txt
/*
awk [-f field-separator] 'commands' input-file(s)
*/
detail describe of awk in bash,please click in:
https://www.cyberciti.biz/faq/bash-scripting-using-awk/
comment: this is my first blog article,if there are something wrong in the article,please point out,thanks.
上一篇: 程序员背后的心酸日常,你懂多少?
推荐阅读
-
Leetcode 195 Tenth Line
-
【Leetcode】149. Max Points on a Line 149. 直线上最多的点数
-
LeetCode 149. Max Points on a Line **** 灵活键,查找表
-
Pipes实现LeetCode(195.第十行)
-
leetcode 149. Max Points on a Line
-
LeetCode刷题笔记(Max Points on a Line)
-
【重要+细节】LeetCode 149. Max Points on a Line
-
Leetcode 195 Tenth Line
-
Leetcode149_Max_Points_on_a_Line
-
LeetCode | 149. Max Points on a Line求多个点里面在一条直线上的点最多有多少个难题