Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you have mysql installed, it comes with a <em>lovely</em> command line util called "replace" which replaces files in place across any number of files. Too few people know about this, given it exists on most linux boxen everywhere. Syntax is easy:</p> <pre><code>replace SEARCH_STRING REPLACEMENT -- targetfiles* </code></pre> <p>If you MUST use sed for this... that's okay too :) The syntax is similar:</p> <pre><code>sed -i.bak s/SEARCH_STRING/REPLACEMENT/g targetfile.txt </code></pre> <p>So if you're just using numbers, you'd use something like:</p> <pre><code>for a in {1..1000} do cp inputFile.html outputFile-$a.html replace kitename $a -- outputFile-$a.html done </code></pre> <p>This will produce a bunch of files "outputFile-1.html" through "outputFile-1000.html", with the word "kitename" replaced by the relevant number, inside the file.</p> <p>But, if you want to read your lines from a file rather than generate them by magic, you might want something more like this (we're not using "for a in <code>cat file</code>" since that splits on words, and I'm assuming here you'd have maybe multi-word replacement strings that you'd want to put in:</p> <pre><code>cat kitenames.txt | while read -r a do cp inputFile.html "outputFile-$a.html" replace kitename "$a" -- kitename-$a done </code></pre> <p>This will produce a bunch of files like "outputFile-red kite.html" and "outputFile-kite with no string.html", which have the word "kitename" replaced by the relevant name, inside the file.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload