我对UNIX非常陌生,我接触的方式是这样的
awk 'BEGIN{ FS = OFS = "|" } { for (i=2;i<=NF;i++) { if(i%2==0) { print $i }}}' newProcessFile.txt
显然它不会产生所需的输出。 我究竟做错了什么 ? 请解释 。
我如何编码一个任意长的pipe道链?
awk或sed来更改文件中的列值
awk使用空格打印从第n个到最后一个的所有列
使用bashparsingiwlist扫描
在awk命令中不能使用“(”
概率每个唯一数字在排除零后排列(长度未知)的概率
如果其他列的AWK写入到新列的基础上
你可以做awk
awk '{for (i=1;i<=NF;i+=2) printf "%s ",$i;print ""}' file
它会打印每隔一列。
cat file one one two one two three one two three four one two three four five one two three four five six
awk '{for (i=1;i<=NF;i+=2) printf "%s ",$i;print ""}' file one one one three one three one three five one three five
与其他分离器:
cat file one one|two one|two|three one|two|three|four one|two|three|four|five one|two|three|four|five|six
awk -F| '{s="";for (i=1;i<=NF;i+=2) {s=s?s FS $i:$i} print s}' file one one one|three one|three one|three|five one|three|five
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。