#!/bin/bash
s="abcd'"'efgh\ ijkl\ mnop'
sed 's/'"'"'/\\&/g' <<< "$s"