I have a series of scripts that make an edit to a crontab file, to enable/disable a job as required. What I'm running into is multiple hash # symbols being injected which I can't figure out how to remove.
Here is how I am doing it:
REMOVE #
[blue]
/opt/csw/bin/gsed -i '/^.*\/usr\/local\/scripts\/mirror-fix\.sh.*/ s/^#//' $TEMPFILE
[/blue]
REPLACE #
[blue]
/opt/csw/bin/gsed -i '/^.*\/usr\/local\/scripts\/mirror-fix\.sh.*/ s/^/#/' $TEMPFILE
[/blue]
This approach may not be optimal, perhaps I just need to grep for the line and delete it, replacing it with another line that has the uncommented/commented entry.
The script should be able to be run repeatedly and not give the result it does, with ## prepended lines.
Otherwise, I am trying to figure out how to tell 'sed' to remove ^#(more than one hash).* up to the next character which is a number (crontab).
Any suggestions, pointers would be really appreciated, this is driving me up a wall... but a good learning experience.
Here is how I am doing it:
REMOVE #
[blue]
/opt/csw/bin/gsed -i '/^.*\/usr\/local\/scripts\/mirror-fix\.sh.*/ s/^#//' $TEMPFILE
[/blue]
REPLACE #
[blue]
/opt/csw/bin/gsed -i '/^.*\/usr\/local\/scripts\/mirror-fix\.sh.*/ s/^/#/' $TEMPFILE
[/blue]
This approach may not be optimal, perhaps I just need to grep for the line and delete it, replacing it with another line that has the uncommented/commented entry.
The script should be able to be run repeatedly and not give the result it does, with ## prepended lines.
Otherwise, I am trying to figure out how to tell 'sed' to remove ^#(more than one hash).* up to the next character which is a number (crontab).
Any suggestions, pointers would be really appreciated, this is driving me up a wall... but a good learning experience.