Skip to content

Commit f7908d7

Browse files
authored
add leetcode
1 parent 227c07f commit f7908d7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

shell/195. Tenth Line.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
How would you print just the 10th line of a file?
2+
3+
For example, assume that file.txt has the following content:
4+
5+
```
6+
Line 1
7+
Line 2
8+
Line 3
9+
Line 4
10+
Line 5
11+
Line 6
12+
Line 7
13+
Line 8
14+
Line 9
15+
Line 10
16+
```
17+
Your script should output the tenth line, which is:
18+
19+
```
20+
Line 10
21+
```
22+
23+
**Hint:**
24+
1. If the file contains less than 10 lines, what should you output?
25+
2. There's at least three different solutions. Try to explore all possibilities.
26+
27+
**Bash**
28+
```
29+
sed -n '10p' file.txt
30+
```

0 commit comments

Comments
 (0)