1

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

4

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;
1
  • 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 .