sed (or STream Editor) is really useful for doing pattern replacement in text output directly on command line.

A simple example that substitutes (s) all (g globally) occurences of x with y. x and y can be replaced with any regular expression.

df -h | sed 's/x/y/g'

sed scripts can also operate on several lines at the same time. Note this script does not handle uneven number of lines. N adds next line to buffer, then new line is substituted, P print the buffer and D deletes the buffer.

ls | sed 'N;s/\n/; /;P;D;'

See sed description at wikipedia for more information.

The following link contains numerous useful examples.