[英]awk: delete short line from long line
我有一长串的文字字符串,按长度排序。 我需要做的是找到长线中包含的任何短线,将长线分成两条短线,并保持原始短线不变,如下所示:
input:
here is an example of a long line
an example of
output:
here is
a long line
an example of
您尚未发布足够的数据集来允许我们发布完整的解决方案,但是以下是一些入门知识:
$ awk '
NR==FNR{
a[$0]++;
next
}
{
for(x in a)
if(x!=$0 && index($0,x)>0) {
sub(x FS,"\n")
}
}1' file file
here is
a long line
an example of
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.