/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" PowerShell : Tabcompletion Part 5 "," PowerShell : Calendar Function (GUI) "," PowerShell : WMI Support in RC2 : Privileges and c... "," PowerShell : WMI Support in RC2 (Series part 2) "," PowerShell : WMI Support in RC2 (Series part 1) "," PowerShell RC2 and Active Directory Part 2 "," PowerShell : Hosting IronPython "," PowerShell RC2 and Active Directory "," PowerShell : Using IronPython to Connect to AD and... "," PowerShell Session video of Bruce Payette "," ")

Thursday, October 19, 2006

 


PowerShell : 99-bottles-of-beer



I came at this page : 99-bottles-of-beer.net ,

I could not resist making and submitting a PowerShell example to it.
I came to this example :

# 99-bottles-of-beer

99..1 |% {("{0} bottle{1} of beer on the wall, {0} bottle{1} of beer.
Take one down and pass it around, {2} bottle{3} of beer on the wall.`n" -f 
$_,$(if ($_ -ne 1){"s"}),($_ -1),$(if ($_ -ne 2){"s"})).replace(' 0',' No more')}


Note, this sample does handle the bottle(s) and 0 = No More, to keep it at least a bit of a chalenge in PowerShell ;-).

Enjoy,

Greetings, /\/\o\/\/
Tags : Monad PowerShell


Comments:
Anonymous Anonymous
I believe you're missing a | character:

99..1 | % {}
 
Anonymous Anonymous
I believe you're missing a | character:

99..1 | % {}
 
Anonymous Anonymous
You have a bug which shows all '0' ending figures like 'No more' - eg '30 bottles' becomes '3No more bottles'. You can fix it by adding a leading space to the replacement strings: replace(' 0', ' No more').
 
Blogger /\/\o\/\/
Thx Both

I had some formatting problems again, the Spaces and Pipeline where lost, I did a repost

greetings /\/\o\/\/
 
Post a Comment



<< Home

Archives

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  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Google
 
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?