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.

1 Answer 1


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. Feb 15, 2019 at 17:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .