how to replace string by other one in a file & without perl ?
Let's take an example:
In file1.txt, for the replaceement of all occurences of "the little bird" by "the little turtle that " Please in C, gambas, bash, sh, ... (but not perl and please not with stuffs like ninja \//\\\\\\//////\\\\\\ ) Thank you ! == (Sorry, but google cannot say which is the best way & easiest ) |
This is something that you do in sed or awk.
If each instance in contained on the same line, and the replacement won't make the line too long, then a single sed command can do it: sed 's/the little bird/the little turtle that/g' file1.txt. However, if the phrase may be split on two lines, you need to add more rules which build up two lines in a buffer and ignore \n characters. The first edition of the O'Reily "Sed & Awk" book may be available on the web. |
Quote:
Then, now, hence, that s the beginning for me working with Awk.I liked yoru help ! I have a book with Awk and will study it. == (When I was googling I was really scared by these \//\\\\\\//////\\\\\\ and my trials didnt worked all the time ) |
Quote:
Code:
#!/bin/sh Code:
#!/usr/bin/python |
Hi.
If you find yourself doing this kind of operation often, you could write your own command to do it simply. Quote:
Code:
gres "the little bird" "the little turtle" filename |
All times are GMT -5. The time now is 01:56 PM. |