>>第一种方法<<
- sed -n '1~2p'
- sed -n '2~2p'
info sed `FIRST~STEP' This GNU extension matches every STEPth line starting with line FIRST. In particular, lines will be selected when there exists a non-negative N such that the current line-number equals FIRST + (N * STEP). Thus, to select the odd-numbered lines, one would use `1~2' |
'FIRST~STEPp'
意为提取行是从FIRST处开始,每隔(步长)为STEP
>>第二种方法<<
awk 'NR%2==1' file
awk 'NR%2==0' file