Editing text files programmatically

It can often be useful to edit text files without manual intervention, in a program.

The tools sed and awk are particularly useful for this.

Editing a line

/bin/sed -i "s/${PATTERN}/${REPLACEMENT}/" $MYFILE

s = substitute

Deleting a block of text

/bin/sed -i "/^;${MARK_START}/,/^;${MARK_END}/d" $MYFILE

d = delete