How to append a RANDOM string to all occurrences of another string in file <p>I'm trying to write a bash script that would modify all occurrences of a certain string in a file. </p> <p>I have a file with a bunch of text, in which urls occur. All urls are in the following format:<code>http://goo.gl/abc23</code> (that's goo.gl/, followed by 4 OR 5 alphanumeric characters).</p> <p>What I'd like do is append a string to all urls. I managed (with the help of user <a href="http://stackoverflow.com/users/34426/dan-fego">Dan Fego</a>) to get this done with sed, but it only works by appending a static string. </p> <p>What I'm looking for is a way to append a <strong>different string to each occurrence</strong>. Let's say I have a function <code>generatestring</code> that echoes a different string every time. I'd like to append a different generated string to each url. <code>http://goo.gl/abc23</code> would become <code>http://goo.gl/abc23?GeneratedString1</code>, <code>http://goo.gl/JB007</code> would become <code>http://goo.gl/JB007?GeneratedString2</code> and so on. </p> <p>Does anyone know if this can be done? I've been told that perl is the way to go, but I have zero experience with perl. That's why I'm asking here.</p> <p>Thanks in advance for any help.</p>