Loading

LeetCode problem#195

Tenth Line

Solved in 1 languageBash

Solve it on LeetCode(opens in a new tab)

Solution

9 lines
1# Read from the file file.txt and output the tenth line to stdout.
2# Solution 1
3head -n 10 file.txt | tail -n +10
4
5# Solution 2
6# awk 'NR==10' file.txt
7
8# Solution 3
9# sed '10!D' file.txt

Want a walkthrough of this Bash solution?

Get a step-by-step explanation of the idea behind the code.

All problems

Problem statements belong to LeetCode and are on leetcode.com. We're not affiliated with LeetCode.