Skip to main content

Posts

Showing posts with the label insert text at specific line in file

SED foo

Uncommenting %wheel NOPASSWD in /etc/sudoers sudo sed -i -e 's/^#\s*\(%wheel\s\+ALL=(ALL)\s\+NOPASSWD:\s\+ALL\)/\1/' / etc / sudoers Remove a line from a file solution: sed -i -e '/IPADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth6 issue: I was moving an interface from a Physical NIC (eth6) to a Bridge (brbkup) therefore, I obviously no longer wanted an eth6 IPADDR entry. Insert text into a file at a specific line solution : sed -i -e '26i\ ' /etc/named.conf sed -i -e '27i\ \ \ \ \ \ \ \ managed-keys-directory\ \"\/var\/named\/dynamic\";' /etc/named.conf issue :  I needed to add a directive into my /etc/named.conf file.  It could not simply be appended and YES, my proposed solution makes quite a few assumptions... most importantly that the location I want my new line is indeed line 26. Before: /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; }; After...