LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Modify a text files with awk/sed/perl (https://www.linuxquestions.org/questions/programming-9/modify-a-text-files-with-awk-sed-perl-640466/)

colucix 08-05-2008 03:35 PM

Why don't you simply open inittab with your favorite text editor?



UAH UAH UAH... YOU MAKE ME LAUGH! :D

Seriously, now. Here is the dirty way:
Code:

cp -p /etc/inittab /etc/inittab.bck
sed -i 's%ca::ctrlaltdel:/sbin/shutdown -t3 -r now%# Changed 8-5-08 -dfezz1 (disabling ctrl-alt-del at console)\nca:12345:ctrlaltdel:/bin/echo "CTRL-ALT-DEL is disabled"%' /etc/inittab

The -i option of sed edits the file in place (hence the backup copy). After the substitute 's' command of sed you can use any character as separator: when you have slashes in the pattern you can escape them using a backslash or chose another separator, as the percent sign in my example. Also you can insert a newline character in the replacement string to span the output on two consecutive lines. Just a dirty way, I know. I will think about a better one for the next couple of minutes! ;)


All times are GMT -5. The time now is 11:37 AM.