Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows CMD TYPE command

Tags:

command

window

I am learning from a tutorial and it used this command type NUL > introduction.js . I searched online TYPE is a command, i know > is redirection operation and last is the name of the file. And it creates an empty file. I dont't know the function of NUL but its equivalent to dev/nul of UNIX.

But can someone summarize the whole command in parts and what is the advantage of doing this instead of echo or other commands.

like image 713
Arjun Chaudhary Avatar asked Oct 22 '25 19:10

Arjun Chaudhary


2 Answers

In Windows command Prompt:

both type & echo can create a file

for creating empty file, for example a text file

TYPE nul > pathNewFile.txt

Echo > pathNewFile.txt

for adding content to new or existing file by Echo

Echo some text > pathNewOrExistingFile.txt

and for Type it puts content of another file

TYPE pathExistingFile.txt > pathNewOrExistingFile.txt

and in both of them for appending content instead of overriding content we use >> for >

Echo some text >> pathFileName.txt
like image 85
Masoud Avatar answered Oct 26 '25 05:10

Masoud


In CMD help:

type /?
Displays the contents of a text file or files.

TYPE [drive:][path]filename

and NUL I think is an empty file symbol. so,

type NUL > introduction.js

reads the content of NUL "Which is an empty file", and write it to introduction.js conclusion:

You are creating an empty introduction.js file.

like image 34
Masked Man Avatar answered Oct 26 '25 03:10

Masked Man