Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

powershell
touch

What is the PowerShell equivalent of 'touch'?

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

svg viewer

In Linux, the touch command is used to generate a new file. However, in PowerShell, this command does not work; so, alternatives are used.

The easiest way is to use:

$null > filename

This generates a file in Unicode, so, the file will not be empty. To generate a file in ASCII use:

$null | sc filename

Another way to create files and folders is to use New-Item:

ni filename

This creates a file or folder,​ depending on the extension given.

Sometimes it is also used to change the timestamps (i.e., dates and times of the most recent access and modification) on existing files and directories.

RELATED TAGS

powershell
touch
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring