-1

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 ";" 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?

Alorher
  • 5
  • 3
  • 1
    Please add sample input (no descriptions, no images, no links) and your desired output for that sample input to your question (no comment). – Cyrus May 25 '20 at 07:47
  • Does [How to compare two decimal numbers in Bash/Awk?](https://stackoverflow.com/questions/11237794/) or [How to compare two floating point numbers in Bash?](https://stackoverflow.com/questions/8654051/) answer your question? – U880D May 25 '20 at 07:53
  • @Alorher, probably typo, but you have syntax error in your code in question. And BTW, there are better tools for your task than awk. You probably know. – Petr Matousu May 25 '20 at 07:59

1 Answers1

1
# 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
Petr Matousu
  • 3,120
  • 1
  • 20
  • 32
  • Thanks for the reply but it doesn' work. And I don't understand this part of the code "echo -e "20;10\n10;10\n18;10\n15;10\n13;10\n21;10". Thanks again – Alorher May 25 '20 at 08:28
  • Try in terminal and you will understand. It just simulates your input. – Petr Matousu May 25 '20 at 08:54