【发布时间】:2021-12-07 21:03:52
【问题描述】:
问题描述
这是我的文件
1
2
3
4
5
6
7
8
9
10
我想通过管道发送这个文件的 cat 输出并接收它
% cat file | some_command
1
2
...
9
10
尝试的解决方案
这是我尝试过的一些解决方案,以及它们的输出
% cat temp | (head -n2 && echo '...' && tail -n2)
1
2
...
% cat temp | tee >(head -n3) >(tail -n3) >/dev/null
1
2
3
8
9
10
# I don't know how to get the ...
% cat temp | sed -e 1b -e '$!d'
1
10
% cat temp | awk 'NR==1;END{print}'
1
10
# Can only get 2 lines
【问题讨论】: