Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to replace part of a string with another one

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
URGENT!!!<br>Please help asap!!!<br>I need to be able to replace part of a string with another one (not of the same length) in a serie of files (severall thousands). I tried to use:<br>cat <i>file</i> ¦ tr a-z A-Z &gt; <i>file2</i><br>but it does clip the last characters of A-Z.<br>Does anyone has another command that can help me<br>Thanks in advance.
 
You can try the stream editor &quot;sed&quot; command:<br><br>sed 's/string1/string2/' file &gt; file2<br><br>This will change the first string1 ONLY on each line.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-or-<br><br>sed '/string1/string2/g' file &gt; file2<br><br>This will change all string1's on each line.<br><br>If you post again, please provide a short example of<br>your input and also an example of the output you are<br>expecting.&nbsp;&nbsp;This will help us to help you wihout trying<br>to second guess your request.<br><br><br><br> <p>flogrr<br><a href=mailto:flogr@yahoo.com>flogr@yahoo.com</a><br><a href= > </a><br>
 
Thanks a ton flogrr,<br><br>you just saved me severall hours of work, hope to be able to do contribute and help somebody once as well.<br><br>Cheers,<br><br>Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top