0

I want to search date and daily new confirmed cases from a csv file by inputing date. This is how I tried:

echo "Enter Date to search Daily new confirmed cases: "
read date
awk -F "," '{if($1 == "$date" ) { print "Date: " $1 ", Daily new confirmed cases: " $2}}' file.csv

But date can't be read inside if condition. Any solution?

Asif
  • 1
  • 1
  • Welcome to SO. Special thanks for adding your efforts in form of code. Request you to please do add samples of input and expected output in your question to make it more clear and let us know then. – RavinderSingh13 Sep 28 '20 at 16:18
  • 1
    Use: `awk -v date="$date" -F, '$1 == date {print "Date: " $1 ", Daily new confirmed cases: " $2}' file` – anubhava Sep 28 '20 at 16:22

0 Answers0