DJMcCarthy12
DJMcCarthy12

Reputation: 4119

Windows Piping to a file from CMD

Quick question that I couldn't find an answer to. When piping to a file as such:

echo "hello" > hello.txt

does this operation actually call notepad.exe on Windows, or is this a non application level file operation?

Upvotes: 1

Views: 2825

Answers (2)

Mathias R. Jessen
Mathias R. Jessen

Reputation: 175065

No, echo is a builtin command in the windows Command Prompt (cmd.exe) used to display/output messages.

The output redirector, >, followed by a file path makes cmd.exe write the message to that file instead of to your screen.


You can see the full list of builtin commands in cmd.exe by typing help at the command prompt

Upvotes: 1

DavidPostill
DavidPostill

Reputation: 7921

echo is an internal command, which means it is built in to the windows command shell cmd.exe.

Source Internal commands:

The Windows CMD shell CMD.exe contains a number of 'internal' commands.

...

ASSOC, BREAK, CALL ,CD/CHDIR, CLS, COLOR, COPY, DATE, DEL, DIR, DPATH, ECHO, ENDLOCAL, ERASE, EXIT, FOR, FTYPE, GOTO, IF, KEYS, MD/MKDIR, MKLINK (vista and above), MOVE, PATH, PAUSE, POPD, PROMPT, PUSHD, REM, REN/RENAME, RD/RMDIR, SET, SETLOCAL, SHIFT, START, TIME, TITLE, TYPE, VER, VERIFY, VOL


Piping (a form of redirection) is also performed by the windows command shell cmd.exe.

See Redirection for more information.


The means that when you execute echo "hello" > hello.txt the whole of the command (the echo followed by the redirection is performed by cmd.exe.

Upvotes: 0

Related Questions