python equivalent to sed
<p>Is there a way, without a double loop to accomplish what the following sed command does</p>

<p>Input:</p>

<pre><code>Time
Banana
spinach
turkey
</code></pre>

<p><code>sed -i "/Banana/ s/$/Toothpaste/" file</code></p>

<p>Output:</p>

<pre><code>Time
BananaToothpaste
spinach
turkey
</code></pre>

<p>What I have so far is a double list which would take a long time to go through both.</p>

<p>List a has a bunch of numbers
list b has a the same bunch of numbers but in a different order</p>

<p>For each entry in A i want to find the line in B with that same number and add value C to the end of it.</p>

<p>Hope this makes sense, even if my example doesn't.</p>

<p>I was doing the following in Bash and it was working however it was super slow...</p>

<pre><code>for line in $(cat DATSRCLN.txt.utf8); do
        srch=$(echo $line | awk -F'^' '{print $1}');
        rep=$(echo $line | awk -F'^' '{print $2}');
        sed -i "/$(echo $srch)/ s/$/^$(echo $rep)/" tmp.1;
done
</code></pre>

<p>Thanks!</p>
