I don't think this question has been asked before, so I don't know if sed
is capable of this.
Suppose I have a bunch of numbers in a sentence that I need to expand into words, a practical example being to swap the numbered citations in a typical essay into MLA format:
essay.txt
:
Sentence 1 [1]. sentence two [1][2]. Sentence three[1][3].
Key.txt
(this is a tab delimited file):
1 source-one
2 source-two
3 source-three
...etc
Expected Result.txt
:
Sentence 1 [source-one]. sentence two [source-one][source-two]. Sentence three[source-one][source-three]
Here's my pseudocode attempt, but I don't understand enough about sed
or tr
to do it right:
cat essay.txt | sed s/$(awk {print $1} key.txt)/$(awk {print $2} key.txt)/g
PS: If there's a trick in notepad++ for mass find-and-replace using multiple terms, that'd be great. As it is, it seems like find-and-replace only works for one term at a time, but I need a way to do it en masse for many terms at once.