The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-29-2001
mexx_freedom mexx_freedom is offline
Registered User
 

Join Date: Jul 2001
Location: Bangalore,India
Posts: 7
Question how to replace certain patterns in a file thru unix!!

Hi Friends,
well what i want to do is that suppose i have a file say like
....
ronaldduckdancecoolman
donaldmuckdancepooltactics
fonaldguckdancetoolbutcomps
....
okok i agree this is a ridiculous data for a file.
:-)
now i want that the characters in each line fromposition 16 to say 19 gets replaced by a particular string , in this case the charcters are cool pool and tool , so say i want is the follwoing output:

....
ronaldduckdanceYYYYman
donaldmuckdanceYYYYtactics
fonaldguckdanceYYYYbutcomps
....

or maybe it is possible that the case is that i want to replcae cool,tool and pool by word whose length is greate than the ones which are present say like

....
ronaldduckdanceYYYYYYYYman
donaldmuckdanceYYYYYYYYtactics
fonaldguckdanceYYYYYYYYbutcomps
....

and also suppose i want say that a particular word occurence in every line is replaced by some other word say like i have input file containing

....
ronaldduckdanceYYYYman
donaldmuckdanceYYYYtactics
fonaldguckdanceYYYYbutcomps
....

and i want the file to be manipulated as
....
ronaldduckdanceXXXXman
donaldmuckdanceXXXXtactics
fonaldguckdanceXXXXbutcomps
....

or say different lengths replacement like
....
ronaldduckdanceXXXXXXXXman
donaldmuckdanceXXXXXXXXtactics
fonaldguckdanceXXXXXXXXbutcomps
....

the bottomline being that there r 2 cases one being replacement being on base of position and the other being replaxcement on basis of certain pattern.

HOW do i do this????
PLzzz help

Regards
Manish
__________________
Manish Joneja
Forum Sponsor