![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Re: ignore whitespace when comparing files using compare-object? Hello Salah, $f1= (get-content v.txt) -replace " " $f2=(get-content p.txt) -replace " " .... Can you attach sample files and an example of the desired output? --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic PowerShell Toolbar: http://tinyurl.com/PSToolbar S> HI, S> S> I currently use the following idea to compare to txt files, S> S> $f1=(get-content v.txt) S> S> $f2=(get-content p.txt) S> S> $total=$f2+$f1|group-object|where {$_.count -lt 2} S> S> you obtain diff between the two files, S> S> Count Name Group S> S> ----- ---- ----- S> 1 Lexmark Optra E312L (MS) {p.txt} S> 1 Lexmark Optra M410 (MS) {p.txt} S> 1 Lexmark Optra S 1255 (MS) {p.txt} S> 1 Lexmark Optra T614 PS {p.txt} S> 1 Lexmark Optra W810 (MS) {p.txt} S> 1 Canon Bubble-Jet BJC-2000 {v.txt} S> 1 Canon Bubble-Jet BJC-240 {v.txt} S> 1 Canon Bubble-Jet BJC-3000 {v.txt} S> 1 Canon Bubble-Jet BJC-4300 {v.txt} S> 1 Canon Bubble-Jet BJC-85 {v.txt} S> 1 Canon Bubble-Jet S450 {v.txt} S> 1 Canon iR330-400 PS Ver... {v.txt} S> where name is the line and group the filename, i've tried to remove S> white Quote: Quote: >> space by using -replace(" ",""), but I loose the group property. If >> someone has a better soluce I'm very interesting by >> >> "bigdave64" <bigdave64@xxxxxx> a écrit dans le >> message de news: >> 251FD85B-0AB7-4DD2-BDF4-526ACBF2D475@xxxxxx... >> >> I was using compare-object recently to compare some text files. I >> quickly discovered that there doesn't seem to be any way to tell >> compare-object to ignore white space differences. Unfortunately, >> this made compare-object almost useless to me, so I switched to >> gnuwin32 diff, which is much more fully featured. >> >> Does anyone know whether compare-object will have more >> options/features under PS 2.0, such as 'ignore whitespace' (-w switch >> with gnuwin32 diff). >> |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Re: ignore whitespace when comparing files using compare-object? | PowerShell | |||
| ignore whitespace when comparing files using compare-object? | PowerShell | |||
| Comparing files with compare-object | PowerShell | |||
| Testing object arrays using Compare-Object and -contains | PowerShell | |||
| Adding canonical aliases for Compare-Object, Measure-Object, New-Object | PowerShell | |||