【发布时间】:2011-11-17 11:00:51
【问题描述】:
我有一个要过滤的文本文件 使用 awk。文本文件如下所示:
foo 1
bar 2
bar 0.3
bar 100
qux 1033
我想在 bash 脚本中使用 awk 过滤这些文件。
#!/bin/bash
#input file
input=myfile.txt
# I need to pass this as parameter
# cos later I want to make it more general like
# coltype=$1
col1type="foo"
#Filters
awk '$2>0 && $1==$col1type' $input
但不知何故,它失败了。正确的做法是什么?
【问题讨论】: