Wiki‎ > ‎

sed infile search/replace

posted Oct 7, 2011, 6:21 PM by Dong Xu   [ updated Feb 26, 2015, 9:56 AM ]
sed -i[.extension] -e "s/XXX/YYY/g" file

-i with .ext to back up original files
-i without .ext, not to back up

Using SED and AWK to Print Lines Between Two Patterns

$ sed -n '/WORD1/,/WORD2/p' /path/to/file
$ sed -n '/FOO/,/BAR/p' test.txt

You can easily find out all virtual host entries from httpd.conf, type
# sed -n '/<VirtualHost*/,/<\/VirtualHost>/p' /etc/httpd/conf/httpd.conf