CAN现场分离器在awk中包含多个字符? [英] Can Field Separator in Awk encompass multiple characters?
本文介绍了CAN现场分离器在awk中包含多个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以使用字段分隔由多个字符?就像我想单独含有它们之间的引号和逗号的话即
Can I use a field separator consisting of multiple characters? Like I want to separate words which contain quotes and commas between them viz.
学校,大学,城市
所以在这里我想设置我的FS是作为,
但我正在逐渐有趣的结果,当我定义我的FS这样。这里是我的code片段。
so here i want to set my FS to be as "," But I am getting funny results when I define my FS like that. Here's a snippet of my code.
awk -F\",\" '
{
for(i=1;i<=NF;i++)
{
if($i~"[a-z0-9],[a-z0-9]")
print $i
}
}' OFS=\",\" $*
在此先感谢:)
推荐答案
是,FS可以多字符。看看下面的测试你的例子:
yes, FS could be multi-characters. see the below test with your example:
kent$ echo '"School","College","City"'|awk -F'","|^"|"$' '{for(i=1;i<=NF;i++){if($i)print $i}}'
School
College
City
这篇关于CAN现场分离器在awk中包含多个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文