问题
I have a crontab file contains many database names such as
10 06 1 * * script DEVE_DB1
10 06 1 * * script TEST_DB1
10 06 1 * * script PROD_DB1
....
I would like to add a comment, # , in front of TEST_DB1 in the entire file so that my cron job will not run all TEST_DB1 jobs.
I found the following script on this site,
sed -e '/TEST_DB1/, s/^/#/'
but I get an error:
sed: 0602-404 Function /TEST_DB1/, s/^/## / cannot be parsed.
Any suggestions would be greatly appreciated.
回答1:
Lose the comma (the space is optional):
sed -e '/TEST_DB1/s/^/#/'
Given the start /TEST_DB1/,, sed would be expecting to find the second address in a range, such as a number, $, or another pattern. The s doesn't fit any of these constructs, hence the error.
来源:https://stackoverflow.com/questions/12014275/how-do-i-add-a-comment-in-front-of-a-line-after-a-key-word-search-match