浏览次数: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.)

本文详细介绍了在Linux环境下使用awk、sed等命令输出文件中奇数行或偶数行的方法,通过具体实例演示了如何实现这一功能。
834

被折叠的 条评论
为什么被折叠?



