Monday, February 25, 2008

2008 Scripting Games!! Beg. Event 3

Event 3 for Powershell this was very simple. My VBScript solution was 14 lines long compared to my one liner in PS.

   1:   ls c:\Scripts | ? {$_.Extension -eq ".txt" } | % {  @(Gc $_.fullname)[0] | ac c:\Temp\newfile.txt} 

Listing all the files in the Scripts folder (LS) for all the text files. Then getting the first line and only the first line @(gc $_.fullname)[0] then piping that line to the Add-content cmdlet to build the new file. Learned that trick from Keith Hill. 8)

No comments: