在正则表达式

时间:2017-09-01 12:36:27

标签: awk

我正在尝试搜索存储在awk数组中的模式“a”从file1读取然后在file2的4rth列中搜索,以下命令工作正常

awk -F" " 'NR==FNR{a[NR]=$1;next}{for (i in a){ if($4 ~ a[i])print $0}}'  file1 file2 

但是如果我在if更改命令以搜索file2的4rth列的开头,如下所示,它不起作用,有什么建议吗?

awk -F" " 'NR==FNR{a[NR]=$1;next}{for (i in a){ if($4 ~ "^a[i]" )print $0}}'  file1 file2 

可以修改第二个命令来搜索file2中4rth列开头的数组元素吗?

1 个答案:

答案 0 :(得分:7)

Caused by: java.lang.OutOfMemoryError: Java Heap Space at java.lang.Class.getMethodImpl(Native Method) at java.lang.Class.getMethod(Class.java:917) at org.apache.lucene.store.MMapDirectory$MMapIndexInput$1.run(MMapDirectory.java:244) at org.apache.lucene.store.MMapDirectory$MMapIndexInput$1.run(MMapDirectory.java:241) at java.security.AccessController.doPrivileged(AccessController.java:327) at org.apache.lucene.store.MMapDirectory$MMapIndexInput.freeBuffer(MMapDirectory.java:241) at org.apache.lucene.store.ByteBufferIndexInput.close(ByteBufferIndexInput.java:295) at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:788) at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:694) at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:400) at org.apache.lucene.index.StandardDirectoryReader.isCurrent(StandardDirectoryReader.java:349) at org.apache.lucene.index.StandardDirectoryReader.doOpenNoWriter(StandardDirectoryReader.java:303) at org.apache.lucene.index.StandardDirectoryReader.doOpenIfChanged(StandardDirectoryReader.java:266) at org.apache.lucene.index.StandardDirectoryReader.doOpenIfChanged(StandardDirectoryReader.java:254) at org.apache.lucene.index.DirectoryReader.openIfChanged(DirectoryReader.java:170) 更改为"^a[i]" ......