I want to develop a script
that will replace any words in file .
I know what I can do with the command (s) below:
$ tr 'ABC' '123' < arquivo.txt > novo-arquivo.txt
or
$ sed "s/ABC/123/g" arquivo.txt > novo-arquivo.txt
However, I do not just want to do the simple exchange of a "word" for "another", but rather make several changes of several " words " inside the file
For example:
I would like
script
to perform substitution in mass .. group / set words that is defined by the user itself. / p>
Suppose the file (document) contains the following words:
- homen Home
- sun Home
- day
Then script
should ask the question about the exchange, something like this:
1) - Type here, all words in which you want to replace them: man, sun, day
2) - Now, type in the same order as before, new ones to be inserted: woman, moon, night
That is, automate change in general, instead of replacing only a single word, it can be more than one in different occurrence.
Conclusion
Then it would be enough to be defined by the user, to make the change in the file simultaneously (at one time). Change a set of words to other that the user can define.