0

Bash: New line in echo string fails when output is piped to crontab.

The \n new line combo seems to be treated as part of the string, while it should be treated as a new line symbol.


Consider:

echo "0 0 * * * ~/cronDaily.sh \n 0 0 * * 0 ~/cronWeekly.sh" | crontab

The current state is the above command prints the following output into crontab:

"0 0 * * * ~/cronDaily.sh \n 0 0 * * 0 ~/cronWeekly.sh

The desired state is a command that would print this to crontab: 0 0 * * * ~/cronDaily.sh 0 0 * * 0 ~/cronWeekly.sh


The above problem happens when the content is piped into crontab.

Why the \n new line is considered part of the string and don't give a new line effect?

Osi
  • 1
  • 3
  • 9
  • 30

0 Answers0