You might try this : perl -pe 's/^replace-this$/line one\nline two\nline three\n/' file1 file2 or cat some_file | perl -pe 's/^replace-this$/line one\nline two\nline three\n/' Oddly enough, perl -ep doesn't work. -ijt