Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to do this in PowerShell? Or : what language to use for file and string manipulation?
    text
    copied!<p>What language should I use for file and string manipulation?</p> <p>This might seem objective, but really isn't I think. There's lot to say about this. For example I can see clearly that for most usages Perl would be a more obvious candidate than Java. I need to do this quite often and at this time I use C# for it, but I would like a more scriptlike language to do this. </p> <p>I can imagine Perl would be a candidate for it, but I would like to do it in <a href="http://en.wikipedia.org/wiki/Windows_PowerShell" rel="nofollow noreferrer">PowerShell</a> since PowerShell can access the .NET library (easy). Or is Python a better candidate for it? If I have to learn a new language, Python is certainly one on my list, rather than Perl.</p> <p>What I want to do for example, is to read a file, make some changes and save it again. E.g.: open it, number all lines (say with 3 digits) and close it. Any example, in any language, would be welcome, but the shorter the better. It is utility scripting I'm after here, not OO, TDDeveloped, unit-tested stuff of course. </p> <p>What I would very much like to see is something as (<a href="http://en.wikipedia.org/wiki/Pseudocode" rel="nofollow noreferrer">pseudocode</a> here): </p> <pre><code>open foobar.as f foreach line in f.lines line.addBefore(currenIteratorCounter.format('ddd') + '. ') close f </code></pre> <p>So: </p> <pre><code>bar.txt Frank Zappa Cowboy Henk Tom Waits numberLines bar.txt bar.txt 001. Frank Zappa 002. Cowboy Henk 003. Tom Waits </code></pre> <p>UPDATE: </p> <p>The Perl and Python examples here are great, and definitely in the line of what I was hoping and expecting. But aren't there any PowerShell guys out there?</p>
 

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