Windows equivalent of 'touch' (i.e. the node.js way to create an index.html)

后端 未结 19 2328
一整个雨季
一整个雨季 2020-11-28 00:47

On a windows machine I get this error

\'touch\' is not recognized as an internal or external command, operable program or batch file.

19条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 01:22

    No command – neither typenor echo– is necessary to emulate Unix's/Mac OS X's 'touch' command in a Windows Powershell terminal. Simply use the following shorthand:

    $null > filename
    

    This will create an empty file named 'filename' at your current location. Use any filename extension that you might need, e.g. '.txt'.

    Source: https://superuser.com/questions/502374/equivalent-of-linux-touch-to-create-an-empty-file-with-powershell (see comments)

提交回复
热议问题