Using a bash script ./find_dates. Code in find_dates

 grep '^2019/02/01' /pi/home/data/*|sort -t: -k2 > /pi/home/files/data.txt;

I am getting data in the data.txt

However when I run ./find_dates2 2019/02/01. Code in find_dates2:

grep '^$1' /pi/home/data/*|sort -t: -k2 > /pi/home/files/data.txt;

The data.txt is empty.


Simple typo - use double quotes instead of single quotes, otherwise the variable doesn't get expanded.

grep "^$1" /pi/home/data/*|sort -t: -k2 > /pi/home/files/data.txt;
  • Thanks. I had that but I didn't think it was working. But I was sending in the incorrect date. Thank you. – user3525290 Feb 15 at 17:25
  • Heh. You're welcome. – tink Feb 15 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.