如何读取文件的前n行和后n行?
对于 n=2
,我读取了 online (head -n2 && tail -n2)
会起作用,但它不会。
$ cat x
1
2
3
4
5
$ cat x | (head -n2 && tail -n2)
1
2
n=2
的预期输出为:
1
2
4
5
最佳答案
head -n2 file && tail -n2 file
关于bash - 如何从文件中读取前 n 行和后 n 行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28615961/