I want to write a shell script that cat
s some file and runs awk
to extracts lines that contain a date that I pass into the script as an argument.
The script will be invoked like /my_script.sh 2021-01-01
Here are the contents of /my_script.sh
.
DATE=$1
cat /myfile | awk -F , '$12 == "$DATE" { print } '
Note that $12 corresponds to the date column that I care about.
When I run this and look at the process with ps aux, I see that the command being run is literally:
awk -F , $12 == "$DATE" { print }
How can I embed the DATE variable inside the double quotes which is inside the single quotes?