2


I have been working on setting a cron job programmatically in a Bash script.
In it I have a line like:

JOB="00 12 * * * sh dosomething.sh"

I noticed if I echoed the var $JOB, it contains the files of the directory?

Is there a way to store the * symbole in a var as a normal character?

Thank you,

Alain
  • 702
  • 2
  • 13
  • 33

1 Answers1

5

You need to quote the variable, for instance when you are echoing it, like so:

JOB="00 12 * * * sh dosomething.sh"
echo "$JOB"

Reference: How do I escape the wildcard/asterisk character in bash?

Community
  • 1
  • 1
Darragh Enright
  • 13,676
  • 7
  • 41
  • 48