是否可以使用awk将不同的行打印到不同的输出文件 [英] is it possible to print different lines to different output files using awk

查看:300
本文介绍了是否可以使用awk将不同的行打印到不同的输出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据不同的条件使用awk将不同的行打印到不同的输出文件,例如

I want to print different lines to different output files using awk, depending on different conditions, like

awk '{if($2>10) print > outfile1; else print > outfile2}' infile

但是该脚本不起作用 怎么修改呢? 谢谢!

but this script doesn't work how to modify it? thanks!>

推荐答案

您需要关闭双引号中的文件名:

You need to close the file names in double quotes:

awk '{if($2>10) {print > "outfile1"} else {print > "outfile2"}}' infile

这篇关于是否可以使用awk将不同的行打印到不同的输出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆