From: Joost Diepenmaat Date: 2005-05-04T23:28:22+09:00 Subject: Re: writing to a file with gsub! On Wed, May 04, 2005 at 11:20:21PM +0900, Ralf M�ller wrote: > On Wed, 4 May 2005 23:06:21 +0900 > James Edward Gray II wrote: > > > On May 4, 2005, at 8:59 AM, Ralf M�ller wrote: > > > > > On Wed, 4 May 2005 22:30:07 +0900 > > > "Robert Klemme" wrote: > > > > > > > > >> But it's simpler - as simple as > > >> > > >> ruby -pi.bak -e 'gsub /\d+/, "###"' your_file > > >> > > > > > > But what about using \1 and \n in the second argument of gsub. Doesn't > > > require \1 single-quotes > > > and \n double quotes? > > > > No. If you want to put \1 in double quotes, just add a backslash. > > "\\1\n" works fine. > > > > Hope that helps. > > > > Great. > At last i can get rid of these perl one-liners. You mean you prefer ruby -pi.bak -e 'gsub /\d+/, "###"' your_file over perl -pi.bak -e 'gsub /\d+/, "###"' your_file ? Yeah, I can clearly see the advantage :-)