浏览次数:60次
1.awk 'NR%2==1' file / /显示奇数行 2.sed -n '1,$n;p' file / /显示偶数行 3.sed -n '1,$p;n' file / /显示奇数行 4.奇数行:sed '2~2d' file / /显示奇数行 5.偶数行:sed '1~2d' file/ /显示偶数行
first~step Match every step’th line starting with line first. For example, ‘‘sed -n 1~2p’’ will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)