Command line syntax

1 users found this article helpful

When using a command, you must know and use the correct syntax of that command. The syntax of a command would be the rules regarding how the command is entered and will include options (if available) that, when included, will cause a change of some sort in the result of running the command. Setting up some commands can be a lot like using grammar to properly write a sentence, but in this case having rules governing where and how to place switches, filenames, and/or other options.

In some cases you can type a command with nothing else, press your Enter key on the keyboard, and see a correct result display. For example, if you want to display the current time in the Command Prompt window you can type time, press Enter, and the time will display. A second line will also display allowing you to Enter the new time. If you press Enter again without entering a new time, the Command Prompt will return to its earlier location.

Other commands only work, or may only give an expected response, if you enter additional information. For example, the command CD, meaning "change directory", will only display the directory you currently are in if nothing else is typed after it. Adding the correct information after CD will allow you to move into another, specific directory.

If a command is typed and then run with the wrong syntax, an error message will display. If you run a command with incorrect syntax from some type of script, such as a batch file, the script will end (i.e. it won't work) without indicating why. If you have redirected the display output to a file (see the end of the next article), that file will include the error message.


Was this article helpful?

Tell us how we can improve it.