{ "data": { "question": { "questionId": "195", "questionFrontendId": "195", "categoryTitle": "Shell", "boundTopicId": 1207, "title": "Tenth Line", "titleSlug": "tenth-line", "content": "

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

\r\n\r\n

Example:

\r\n\r\n

Assume that file.txt has the following content:

\r\n\r\n
\r\nLine 1\r\nLine 2\r\nLine 3\r\nLine 4\r\nLine 5\r\nLine 6\r\nLine 7\r\nLine 8\r\nLine 9\r\nLine 10\r\n
\r\n\r\n

Your script should output the tenth line, which is:

\r\n\r\n
\r\nLine 10\r\n
\r\n\r\n
Note:
\r\n1. If the file contains less than 10 lines, what should you output?
\r\n2. There's at least three different solutions. Try to explore all possibilities.
\r\n", "translatedTitle": "第十行", "translatedContent": "

给定一个文本文件 file.txt,请只打印这个文件中的第十行。

\n\n

示例:

\n\n

假设 file.txt 有如下内容:

\n\n
Line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\nLine 7\nLine 8\nLine 9\nLine 10\n
\n\n

你的脚本应当显示第十行:

\n\n
Line 10\n
\n\n

说明:
\n1. 如果文件少于十行,你应当输出什么?
\n2. 至少有三种不同的解法,请尝试尽可能多的方法来解题。

\n", "isPaidOnly": false, "difficulty": "Easy", "likes": 105, "dislikes": 0, "isLiked": null, "similarQuestions": "[]", "contributors": [], "langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}", "topicTags": [ { "name": "Shell", "slug": "shell", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "Bash", "langSlug": "bash", "code": "# Read from the file file.txt and output the tenth line to stdout.", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"40.8K\", \"totalSubmission\": \"92.9K\", \"totalAcceptedRaw\": 40788, \"totalSubmissionRaw\": 92856, \"acRate\": \"43.9%\"}", "hints": [], "solution": null, "status": null, "sampleTestCase": "Line 1\\nLine 2\\nLine 3\\nLine 4\\nLine 5\\nLine 6\\nLine 7\\nLine 8\\nLine 9\\nLine 10", "metaData": "{\n \"shell\": true,\n \"manual\": true\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [], "enableRunCode": false, "envInfo": "{\"bash\":[\"Bash\",\"

\\u7248\\u672c\\uff1aBash 4.3.30<\\/code><\\/p>\"]}", "book": null, "isSubscribed": false, "isDailyQuestion": false, "dailyRecordStatus": null, "editorType": "CKEDITOR", "ugcQuestionId": null, "style": "LEETCODE", "exampleTestcases": "Line 1\\nLine 2\\nLine 3\\nLine 4\\nLine 5\\nLine 6\\nLine 7\\nLine 8\\nLine 9\\nLine 10", "__typename": "QuestionNode" } } }