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

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). Commented May 25, 2020 at 7:47
  • Does How to compare two decimal numbers in Bash/Awk? or How to compare two floating point numbers in Bash? answer your question? Commented May 25, 2020 at 7: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. Commented May 25, 2020 at 7:59

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

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
Try in terminal and you will understand. It just simulates your input.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.