Excuse me if it is a repeat. I have crontab entries which look like:
* * * * * sleep 15;/etc/opt/wer.sh
1 * * * * /opt/sfm/qwe/as.sh
How to insert a # on the line which contains a call to “as.sh” using sed?
How to uncomment it back?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use:
which will replace the start-line zero-width marker with a comment character for all lines containing
/as.sh, as shown in the following example:But you need to keep in mind a couple of things.
cronthat it needs to re-read it. This is automatic if you use thecrontabcommand itself but you may have to send a signal tocronif you’re editing the file directly.To get rid of the marker, use:
This is the opposite operation, it finds those lines containing
/as.shand substitute any#character at the start of the line with nothing.