I have a file that contains the following lines:
...
# Check the date
date
...
I want to comment out the date command. But it occurses a few times in the file and I want to comment the date which is located right one line after the # Check the date, otherwise I would just use:
perl -i -pe 's:(.*date.*):#$1:' file
How can I improve my logic and comment out only the date right after the # Check the date comment?