Why doesn't my Perl one-liner work on Windows?

后端 未结 2 1085
执笔经年
执笔经年 2020-11-30 11:28

From the Windows command prompt I generate a text file of all the files in a directory:

dir c:\\logfiles /B > config.txt

Output:

2条回答
  •  无人及你
    2020-11-30 12:01

    ephemient's answer summarizes the problem well, but you do have another option: change your shell from cmd.exe to a better shell. If you are a Unix type person then I would suggest looking into Cygwin which provides the sort of environment you are used to (for example, Bash and GNU utilities).

    If you are a Windows-type person I would suggest looking at PowerShell (née MSH née Monad). In fact, I would suggest looking into PowerShell even if you are Unix type person. It integrates with .NET and has many neat features (like objects being passed through pipes rather than simple lines of text). If I were stuck on a Microsoft OS, it is the shell I would be using.

    Other shells for Windows that people seem to like:

    • UWIN
    • MinGW
    • UnixUtils
    • Microsoft Windows Services for UNIX (SFU)
    • MKS Toolkit

提交回复
热议问题