In PowerShell, you have to use -lt
and -gt
, instead of <
and >
in comparation, like POSIX sh
.
Especially if you wrongly use >
like below, the comparison will be silently failed (evaluated as $false
) and value of left-hand operand is wrote to a newly created file named “8”.
if ($_.length > 8) { ... }
For comparison, if you wrongly use <
in comparison, comparison will cause an error like:
PS > if ($_.length < 8) { "a" } At line:1 char:15 + if ($_.length < 8) { "a" } + ~ The '<' operator is reserved for future use. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : RedirectionNotSupported