简体   繁体   English

Bash/Linux - 比较脚本中的十进制数字,来自 a.csv 列的数据

[英]Bash/Linux - Compare decimal numbers in a script, data from a .csv column

I am trying to compare the decimal numbers in a column one by one.我正在尝试一一比较一列中的十进制数字。 These comparisons are made with respect to constants.这些比较是针对常数进行的。

I want to count the number of times the condition is true.我想计算条件为真的次数。 But this part is ok.但是这部分没问题。

The file with the data is a csv separated by ";"带数据的文件是一个csv,用“;”隔开and the decimals are separated by a "."小数点之间用“.”隔开。

I have the following code, but I have not achieved anything.我有以下代码,但我没有取得任何成果。

fixed_acidity_filter=$(awk 'BEGIN{FS=";"} {if($1>0 && $1<15) ]{print}}' winequality-white_sincabecera.csv | wc -l)

Can anyone help me?谁能帮我?

# concept
echo -e "20\n10\n18\n15\n13\n21" | awk '{if($1>0 && $1<15) print $1}'
# your code
echo -e "20;10\n10;10\n18;10\n15;10\n13;10\n21;10" | awk 'BEGIN{FS=";"} {if($1>0 && $1<15) print $1}' | wc -l

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM