Ok,Oh, all right
the onliner from last post (" PowerShell : How can I tell witch numbers are missing from a sequence of numbers found in a text file ? ,
gc test.txt | sort {[int]$_} |% {$i = 1}{while ($i -lt $_){$i;$i++};$i++}
was maybe a bit to tiny to post without any explanation.
you can do very powerfull things on the commandline like this, but for in a script or example this might not very handy.
I still not going to explain it,
but I will make it a lot more Clear what Happens, by showing that you do not have too be so tiny in PowerShell , you can write this in a more verbose and readable way , as the former one-liner Can also be written as Follows :
This code does exactly the same as the on-liner, is a bit more work, but much more clear for code you or somebody else might have to read or change.
*Edit* some other suggestions given on IRC for handling this question are :
*Edit 2* Another tip : Need for speed, use another cool feature from Powershell go .NET directly :
[int[]]$a=[io.file]::ReadAllLines('c:\powershell\test.txt')
[array]::sort($a)
Enjoy,
Greetings, /\/\o\/\/
Tags : Monad msh PowerShell
October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 April 2006 May 2006 June 2006 July 2006 August 2006 September 2006 October 2006 November 2006 December 2006