The commands from the other two are very powerful, possibly too powerful. sed will textually replace any occurrence of a consecutive string of characters with the new ones, even if the old characters are part of a larger word e.g. 'the' is a substring of 'these' and sed s'/the/tea/' will output 'tease' rather than an unchanged 'the'.
perl is good for this: it has delimiters for word boundaries and the appropriate command is s/\bthe\b/tea/;
Before making the substitutions, it is worth testing the hypothesis that there are no substrings.
Quote:
Originally posted by msetjadi
HI All,
I am very new in unix and i am not familiar if my requirements can be done in unix.
I need to replace a common word that exists inside thousands file,is impossible to edit one by one.
To all expert, are there any unix command that i can use to do this.
It might not be possible to do it once probably i need to creat a script but is it possible?
Do you know if there is a ready example?
|