Error “The ‘<‘ operator is reserved for future use.” (SOLVED)

Analog “<” for PowerShell

On Linux, you can use the following construct:


In this case, COMMAND1 will be executed with FILE1 as the input source instead of the keyboard, which is the normal standard input source.

The “<” operator corresponds to the use of “|” to be passed to standard input. For example, the following commands are identical:


Trying to use this construct in PowerShell throws an error.

For example command

mysql -uroot < C:\Users\MiAl\Downloads\all-databases.sql

ends with the following message:

Line |
   1 |  mysql -uroot < C:\Users\MiAl\Downloads\all-databases.sql
     |               ~
     | The '<' operator is reserved for future use.

Similar error in PowerShell 5:

string:1 character:14
+ mysql -uroot < C:\Users\MiAl\Downloads\all-databases.sql
+              ~
The '<' operator is reserved for future use.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RedirectionNotSupported

Instead of syntax


you need to use the following structure:

Get-Content FILE1 | COMMAND1

The Get-Content cmdlet will read the contents of FILE1. Symbol “|” (pipe, conveyor) means to pass the content to COMMAND1.

Thus, instead of

mysql -uroot < C:\Users\MiAl\Downloads\all-databases.sql

you need to use the following command:

Get-Content C:\Users\MiAl\Downloads\all-databases.sql | .\mysql -uroot

“./program < input.txt > output.txt” alternative for PowerShell

Consider the construction

./program < input.txt > output.txt

It means that the contents of the input.txt file are passed to the standard input of the “program” command, and the result of program execution is redirected to the output.txt file. But the above command will not work.

An analogue of the considered construction, which will work in PowerShell, is the following command:

Get-Content INPUT.txt | ./program > output.txt

Or you can use the PowerShell style variant:

Get-Content INPUT.txt | ./program | Out-File output.txt

Leave Your Observation

Your email address will not be published. Required fields are marked *