2 ms·
AFAICT, you are just trying to check if a file is sorted? Then wouldn't: diff (cat out.txt | sort | out-string) (cat out.txt -raw) do it?
by bjourne 11y ago
AFAICT, you are just trying to check if a file is sorted? Then wouldn't:
diff (cat out.txt | sort | out-string) (cat out.txt -raw)
do it?
- slavik81 11y agoYeah, actually. Though, I'd still include the cast to int, because I need to sort numerically, not lexicographically. I suppose the lesson is that if you want to preserve line order, you need to use -raw to prevent Get-Content (cat) from splitting the file into multiple lines. That still ruins the output text from Compare-Object (diff), but it's cleaner than fc.exe. Thanks.