I am experiencing a strange behavior using a sed command (got to be sed, no awk in this case) and got two questions for you, hoping someone got the skills to explain me what I am doing wrong.
I want to append a comment and two commands to /etc/sudoers using the following one-liner:
sed -i -e '$a\# Provide apache user permissions to run the ban_ip.sh script as part of mod_evasive\n\apache ALL=NOPASSWD: /usr/local/bin/scripts-tecmint/ban_ip.sh\n\Defaults:apache !requiretty' /etc/sudoers
Strage things happening here:
- The first line (a comment) gets appended at the end of the file directly without an empty line created (just a "design thing" I´d linke to fix)
- The second line created starts now with ^Gpache instead of apache
1. How can I append an emtpy line using my sed one-liner to the end of the file and then having my text inserted after that empty line?
2. What do I need to fix in my one-liner to have sed adding the text I want (2nd line to start with apache and not ^Gpache
Your input is much appreciated.