4
I want to develop a script
which will replace any words in filing cabinet.
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 only wish to exchange a single "word" for "another", but rather, to make several changes of several "words" within the file(document)
For example:
I would like the
script
perform substitution in mass .. group/set words that will be defined by the user himself.
Suppose the file(document) contains the following words:
- man
- sun
- day
Then the script
should ask the question about the proper exchange, something like that:
1) - Type here all words in which you want to replace them: man, sun, day, day
2) - Now, type in the same previous order, the new ones to be inserted: woman, moon, night
That is, automating change generally, rather than replacing only a single word, may be more than one in different occurrence.
Completion
Then it would be enough to be defined by the user, to make the exchange on itself filing cabinet simultaneously (at once). Change a wordset for others that the user himself can define.
With sed you can also use a line: sed -i -e’s/.... /.../; s/.../.../;...'
– zentrunix