head && tail

head && tail

Tutorial

head -n 10 : 列印最前 10 行

tail

tail -n 10 : 列印最後 10 行

tail -f <file.txt> : Following mode 持續列印

tail -n +1 ./*.txt : Print all *.txt with filename

1
2
3
4
5
6
7
==> ./1.txt <==
1
2

==> ./2.txt <==
3
4

印中間 (head + tail)

1
2
3
4
5
6
7
8
9
10
11
cat file.txt
1
2
3
4
5
6

cat file.txt | tail -n 4 | head -n 2
3
4
Author

Meow Lucian

Posted on

2022-06-21

Updated on

2022-07-04

Licensed under

Comments