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

Re: Scripting help please



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.

[ewilts corpftp2 ewilts]$ cat foo
109889-01 : 109353-04,109353-04 :  :  $ SUNWkvmx, SUNWkvm, SUNWctu, SUNWmdb
[ewilts corpftp2 ewilts]$ replace ', ' '* ' -- foo
foo converted
[ewilts corpftp2 ewilts]$ cat foo
109889-01 : 109353-04,109353-04 :  :  $ SUNWkvmx* SUNWkvm* SUNWctu* SUNWmdb

-- 
Ed Wilts, RHCE
Mounds View, MN, USA
mailto:ewilts ewilts org
Member #1, Red Hat Community Ambassador Program


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