Sed to extract email addresses from file

sed -e "s/^.\*<\(.*\)>.*$/\1/" /file_with_emails | sort | \\ uniq | tr "[:upper:]" "[:lower:]" PS: Filip, he’s terribly smart, I guess the only one to read my blog, pointed out the following one-liner: sed -nr "s/.*<([A-Z0-9._%-+]+@[A-Z0-9.-]+\.[A-Z]{2,4})>.*/\L\1/pi" \\ file_with_emails | sort -u Comments: Filip - Jun 4, 2012Hi. This one does the lowercase conversion immediately and lists only e-mails in a valid format. sed -nr "s/.*.*/\L\1/pi" file_with_emails | sort -u Filip - Jun 4, 2012Sorry, WP isn’t friend of my sed oneliner. [Read More]
sed 

Sed oneliner to change Centos 4 repos to vault.centos.org

Centos 4 is now EOLed. You should upgrade or remove your 4.x server from production. Since EOL all repositories have been moved to vault.centos.org. Yum is not working any more because of that. Here is my quick and dirty solution.

sed "s/\/mirror\.centos\.org\/centos/\/vault\.centos\.org/g;\
s/^#baseurl/baseurl/g;\
s/^mirrorlist/#mirrorlist/g;\
s/\$releasever/4\.9/g" /etc/yum.repos.d/CentOS-Base.repo -i.bak

sed "s/\/mirror\.centos\.org\/centos/\/vault\.centos\.org/g;\
s/^#baseurl/baseurl/g;\
s/^mirrorlist/#mirrorlist/g;\
s/\$releasever/4\.9/g" /etc/yum.repos.d/CentOS-fasttrack.repo -i.bak
centos  sed 

Add line to the top of files with sed

One-liner to add line at the beginning of the file(s).

find mirrors-* -exec sed -i 1i'http://webmel53.vsb.cz/hrb33/el$releasever/hrb/stable/$basearch/' {} \\;
sed 

Sed to correct path lines

Sed one-liner to change correct paths. Before:

php_admin_value open_basedir /srv/www/www.domena.tld/www

After:

php_admin_value open_basedir /srv/www/www.domena.tld

Sed script:

sed -i "s/\(.*\)php_admin_value open_basedir \(.*\)\/www$/\1php_admin_value open_basedir \2/g" /etc/httpd/conf/httpd.conf
regex  sed