I need to comment out an entry in rc.tcpip file inside /etc# Start up the snmpmibd daemon   start /usr/sbin/snmpmibd $src_running# Start up the Simple Network Management Protocol (SNMP) daemon   start /usr/sbin/snmpd $src_runningHow do I comment these lines using sed?
How can I comment out snmpmibd and snmpd in rc.tcpip in AIX using sed?
sed;scripting
To comment out lines that start with start /usr/sbin/snmpmibd, use the s command with a pattern using the ^ anchor and # in the replacement text, plus & which stands for the replaced text. You can either match the two lines separately, or notice that snmpd is snmpmibd with mib omitted (concision at the expense of clarity) and use snmp\(mib\)\{0,1\}d. Since the pattern contains a slash, use another character as the delimiter, such as !. Since sed is a filter, you'll need to write the output to a new file, then move the new file into place (redirecting the output of sed to the same file as the input wouldn't work: it would first erase the old file, then start reading from the now-empty file).sed -e 's!^start /usr/sbin/snmpmibd !#&!' -e 's!^start /usr/sbin/snmpmibd !#&!' </etc/rc.tcpip >/etc/rc.tcpip.newmv /etc/rc.tcpip.new /etc/rc.tcpipTo edit a file in place, you can use ed instead of sed.ed -s /etc/rc.tcpip <<'EOF'g!^start /usr/sbin/snmpd ! s/^/#/g!^start /usr/sbin/snmpmibd ! s/^/#/wqEOF  AIX doesn't have \? or \| operators, only started BRE, so \(snmpmibd\|snmpd\) won't work.  AIX sed doesn't have -i, that's a GNU extension.  