On Tue, Apr 02, 2013 at 04:29:59PM +1100, Sam Watkins wrote: > > What is the shortest shell command you can write, > that replaces $A with $B in a text stream for any A and B? > A1="$(printf '%s' "$A" | sed 's,",\\",g; s,\\,\\\\,g')" B1="$(printf '%s' "$B" | sed 's,",\\",g; s,\\,\\\\,g')" awk '{ gsub("'"$A1"'", "'"$B1"'"); print }' textfile
A little gross, maybe. So is the question.