我有一個文本文件,我想用awk過濾 。該文本文件看起來像這樣:Howto在Bash腳本中將字符串作爲參數傳遞給AWK
foo 1
bar 2
bar 0.3
bar 100
qux 1033
我想用awk在bash腳本中過濾這些文件。
#!/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
但不知何故,它失敗了。什麼是正確的做法?
謝謝你,謝謝yoooou :))......你不知道多少走上找到這樣的答案......再次謝謝主席先生 – 2014-08-05 19:48:17