Search code examples
pythoncommand-linedos

How to pass file contents to a python script on windows


I would like to pass the contents of a file along with some other parameters to a python script on windows.

On linux, I can do it like this:

less input.txt | my_script.py  > output.txt

On windows I tried the following but it doesn't seem to work:

more input.txt | python my_script.py  > output.txt

Any idea what I'm doing wrong?


Solution

  • Use following command. It works both in Linux and Windows.

    python my_script.py < input.txt > output.txt