Use ed instead of sed

Search and replace with ed

ed can be used in place of sed to modify a file directly.. The format is straightforward if you have an example. Here is an example that changes the mailquota size for Maildir++.

# cat maildirsize
s8909889098
# ed maildirsize << EOF 
> ,s/s[0-9]+ /s552428800 /g 
> wq 
> EOF 
# cat maildirsize
s552428800 
#

Inject search result into replacement string

What if you want to put the results of the last search back into the
string. You can use the ‘&’ symbol for that.

# cat test
this is test
# ed test << EOF
> ,s/is/& a/g
> wq
> EOF
# cat test
this is a test

Apache Notes

Setup server-status handler on Apache

1) Download rstatd.
2) Build and install rstatd:

$ tar xvzf rstatd.tar.gz
$ cd rpc.rstatd
$ ./configure --prefix=/usr
$ make
# sudo su
# make install

3) Add a line to /etc/hosts.allow to allow certain hosts to make rstatd requests:

rpc.rstatd:     192.168.0.0/255.255.255.0

4) Add rstatd entry in /etc/xinetd.d/rstatd:

# default: off
# description: An xinetd internal service which rstatd's characters back to clients.

service rstatd
{
    type            = RPC
    rpc_version     = 2-4
    socket_type     = dgram
    protocol        = udp
    wait            = yes
    user            = root
    only_from       = 10.0.95.0/24
    log_on_success  += USERID
    log_on_failure  += USERID
    server          = /usr/sbin/rpc.rstatd
    disable         = no
}

5) Restart xinetd:

# /etc/rc.d/init.d/xinetd restart