[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Scripting help please



On Wed, May 04, 2005 at 09:59:08AM -0500, Ed Wilts wrote:
> On Wed, May 04, 2005 at 06:34:30PM +0530, Truejack wrote:

> > I need some scripting help please.
> > 
> > I have a file which has the following output.
> > I need to change all the commas after the $ to a * (or any other
> > character other than a comma).
> > Only the commas after the $ need to be changed.
> > 
> > 109889-01 : 109353-04,109353-04 :  :  $ SUNWkvmx, SUNWkvm, SUNWctu, SUNWmdb
 
> If you have the mysql package installed, you've got a fantastic tool
> called replace.  In my opinion, this should be taken out of mysql and
> bundled in a more common location like coreutils.  You don't need a
> mysql server running - just the client package installed.
> 
> replace ', ' '* ' -- $filename
> 
> replace can process multiple files at once and does the changes in
> place.

How is this any better than "sed -i", e.g.,
sed -i 's/, /* /g' filename

or, to keep a backup as filename.bak:
sed -i.bak 's/, /* /g' filename

Of course this problem becomes trickier if the initial comma also has a
space after it or something.

w


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]