sed '/enabled=1/a\priority=10' /etc/yum.repos.d/epel.repo
Especifique uma opção de edição no local ( -i
) se você quiser (faz o backup com a extensão .bak
primeiro):
sed -i.bak '/enabled=1/a\priority=10' /etc/yum.repos.d/epel.repo
Now i want use sed to do the following 1.Find the FIRST occurrence of worker_processes in that conf and replace text with worker_processes 4;
sed '0,/worker_processes [0-9]*;/s//worker_processes 4;/' /etc/nginx/nginx.conf
One last suggestion I used
sed -i 's/enabled=0/enabled=1/g' /etc/yum.repos.d/remi.repo
to changeenabled=0
toenabled=1
under the[remi]
section inremi.repo
. However i have a feeling that it may modify allenabled=0
in that file , which will wreak the server.Can anyone suggest a better code
Aqui para você:
sed '/\[remi\]/,/enabled=0/ { s/enabled=0/enabled=1/ }' remi.repo
Another stuff i am not sure of:P I want to edit a file that has this as Text Testing = "0"(Yes it has quotes and i need to keep it) It should be modified from Testing = "0" to Testing = "1"(with quotes)
sed 's/Testing = "0"/Testing = "1"/g'
Also i need to add some text with quotes at the end of a file with sed Like "Thanks Quanta"(with quote) For php you put a \ with echoing quotes , don't know how it is done for bash
sed '$a"Werulz, you are welcome"\'
Another thing I need to modify a line in a conf but i don't remember what is the whole of text to replaced
Like its listen = something; , i want to modify it to listen = /tmp/php5-fpm.sock;
sed 's/listen = .*/listen = \/tmp\/php5-fpm.sock;/'