I am writing a sed command that should uncomment an entry in crontab. Is there a better way to do this? The first option that comes to mind is sed.
Example:
Whether using sed or other tool whould not make much a difference. I'd use sed also.
But to properly modify what cron is using, please mind to use crontab
command.
Do NOT try just editing the data file (e.g. /etc/crontab
on some systems). Cron won't pick up the changes!!!.
You might use a pipe:
crontab -l | sed -e "s#\# 5 \* \* \* 3 bash test.sh#5 * * * 3 bash test.sh#"| crontab
to perform the change.
Nevertheless, would it not just be simpler to add the functionality of enabling/disabling into the script being run?