You can also use tee
command to store the output of a command in a file and redirect the same output to another command.
The following command will write current crontab entries to a file crontab-backup.txt
and pass the crontab entries to sed
command, which will do the substituion. After the substitution, it will be added as a new cron job.
$ crontab -l | tee crontab-backup.txt | sed 's/old/new/' | crontab –