小编pet*_*uis的帖子

在 AWK 中使用 IF 语句

我正在编写大脚本,我一直在坚持这一部分,如果有人可以帮助我,请

这是文件示例

31:49.9,9.92,TCP ,1_19,490,EXT_SERVER,22,5,257,1,.ASF,0,normal
Run Code Online (Sandbox Code Playgroud)

这是我脚本的一部分

read -p "Please input the function itself ex, > : " function
read -p "Please input the value: " value
Run Code Online (Sandbox Code Playgroud)

如果我像这样使用,对我来说很好用

cat temp | awk -F',' -v val="$value" '{if($8 > val) print $0}' > $destfile
Run Code Online (Sandbox Code Playgroud)

但是当我尝试这样使用时

cat temp | awk -F',' -v val="$value" -v fn="$function" '{if($8 fn val) print $0}' > $destfile
Run Code Online (Sandbox Code Playgroud)

谢谢

linux bash awk variable

0
推荐指数
1
解决办法
74
查看次数

标签 统计

awk ×1

bash ×1

linux ×1

variable ×1