嗨,我有两个输入文件。
input1.txt文件:

id above
id below
id still
id getting

input2.txt文件
id above
value above the sky

id below
value under the chair

我试图做一个awk命令,它显示为空。
 awk -f find.awk input1.txt input2.txt

我知道我的awk工作,因为我输入2个不同的txt文件和所有的输出是正确的和可见的。
不同input2.txt文件之间的区别是。。。
当我在windows机器上使用记事本时,整个文件都是一个字符串,而如果你使用任何txt编辑器,它都是用单独的行格式化的。
记事本上的input2.txt示例。
  id above value above the sky id below value under the chair

我不能用id重新分析这个输入,因为我真正的txt文件有更多的数据。。。这是不一致的,所以我不能只搜索字符串或注册表表达式。
找到.awk
 FNR==NR  { id[$0]; next }
 $0 in id { f=1 }
 f
 NF==0    { f=0 }

想知道为什么我的锥子不工作了吗?

最佳答案

对输入文件运行“dos2unix”,然后对它们运行awk。我是dos2unix。

关于linux - 不能正确读取输入文件的脚本awk,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15372619/

10-10 17:44
查看更多