Getting Started With Windows Command Prompt.

Directory

Dir > t.t   – this means that the output of the dir command will go to the t.t file. The > symbol is used to redirect the output of a command into a file, for example, to put the output into a text file. To format the file in a different manner, I would use this command. Dir/s /b >t.t . What this does is list all files and directories in the current directory and subdirectories then (/s) then listing the output as the bare minimum (/b) which would just be the directory and path file. The > t.t part redirects this output into the t.t file.

Sort t.t | more – This command sorts the content of t.t alphabetically, and the more command displays the sorted output one screen at a time. The pipe (|) is used to connect commands, allowing the output of one command to be sent as input to another. It is different from >, which is used specifically to redirect output to a file. You can also add /b to show files and directory with out the details. For example, dir /b | sort | more will list the files and directories in the bare format, sort them and then display them page by page.

Overall > is used to redirect the output of a command to your file which would be overwritten every time. But if you want to add to your file or append to it, you’ll use >>.

Date Command Example

Date > t.t – This command will prompt for a new date as input. Let me explain: when you run the date command, it asks for a new date. If you redirect its output to a file using >t.t , it will wait for input but nothing will be written to the file until the new date is entered. To not avoid waiting for input you can either use the command date /T , which outputs the current date without asking for a new one, or you can use a special file like enter.key to handle input automatically.

Special Example Using Input File:

Copy con enter.key – This command allows you to create a file named enter.key that will record keystrokes. To finish, press Ctrl + Z. For example, you could use this command to record an “Enter” keypress and then use it with the date command like this: type enter.key | date >> t.t. This way, the “Enter” keypress is automatically fed to the date command, preventing the prompt from waiting for input, and the data is smoothly added to the t.t file/

Adding Text to a File:

To add text to file in command prompt, use echo ‘[insert text]’ >> t.t .

time is the same as date. You also need to add /T to remove the input of new time.

Glossary

  • Dir: Lists files and directories in the current directory.
  • >: Redirects output to a file, overwriting the file if it exists.
  • >>: Redirects and appends output to a file without overwriting it.
  • Sort: Sorts the contents of a file or output alphabetically.
  • More: Displays output one screen at a time.
  • | (Pipe): Redirects output from one command to another command as input.
  • Date: Displays or sets the system date.
  • Time: Displays or sets the system time.
  • Echo: Displays a message or appends text to a file.
Scroll to Top