The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
grep patterns - File dhanamurthy Shell Programming and Scripting 1 05-08-2008 07:24 PM
How to cut multiple patterns from a file? Vijay06 Shell Programming and Scripting 5 11-26-2007 05:38 PM
How to replace the string in unix file? param_it UNIX for Dummies Questions & Answers 5 06-26-2007 06:06 AM
c++, design patterns and Unix mihk High Level Programming 3 04-25-2007 11:02 PM
replace delimiter : with '\001' in unix data file spandu Shell Programming and Scripting 4 04-25-2006 05:51 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-29-2001
Registered User
 

Join Date: Jul 2001
Location: Bangalore,India
Posts: 7
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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
Forum Sponsor
  #2 (permalink)  
Old 08-29-2001
rwb1959's Avatar
Registered User
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
pattern replacement

Sounds like you need "sed".
Check out...
http://wwwinfo.cern.ch/dis/texi2html...2/sed_toc.html
  #3 (permalink)  
Old 08-29-2001
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
aye sed does soudn liek the way you want to go.

sed 's/.ool/&ltreplacement string&gt/'
  #4 (permalink)  
Old 08-30-2001
Registered User
 

Join Date: Jul 2001
Location: Bangalore,India
Posts: 7
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Hi,
Thanks a lot pals , one of the problems is solved but still one exists.
i am unable to replace based on positions,
could u shed some light on that part plzzzz.
Regards
Manish
  #5 (permalink)  
Old 08-30-2001
flim flam flamma jamma
 

Join Date: May 2001
Location: Chicago IL, USA
Posts: 1,006
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
you will want to look into sed. we gave you the key to open the door. you just have to turn the knob.

you will want to look into regular exprestions also.
Google UNIX.COM
Closed Thread



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 09:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102