Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to replace text that appears several times in a .txt file with a unique value each time? To be more specific:

This is the given document:

other text*
other text*

This is a text file from which I want to take the values:


What I want is to automatically replace "something" with a different value each time taken from the other text file, so the given document will turn into this:

other text*
other text*
share|improve this question
What operating system are you using? This is very easy in the *nix world. Is this a simple text document or something more complex like a Word .doc? – terdon Apr 14 '13 at 17:38
It'd be easy in the Windows world too, I'd use Autoit - very simple to use text manipulation functions. – MaQleod Apr 14 '13 at 17:42
I know this is just an example, but you should write actual values instead of "other text" or any replacement text. We need to focus on your example corpus to answer, so it needs to totally reflect what is your content, without any ambiguity. Or maybe it actually content "other text" each two lines? – leye0 Apr 14 '13 at 17:46
I am using Windows and simple text documents. "other text" replaces more lines of text that need to stay untouched. – Jake Billman Apr 14 '13 at 17:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.