Re: [dev] print utility

From: Noah Birnel <nbirnel_AT_gmail.com>
Date: Tue, 2 Apr 2013 18:32:19 -0700

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.
Received on Wed Apr 03 2013 - 03:32:19 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 03 2013 - 03:36:05 CEST