# Command-line Computing Exercise

## Command Prompt (Windows OS)

Open the Command Prompt application.

> FYI: If you are into maximum efficiency through keyboard shortcuts, get there quick by pressing the "windows" button, then begin typing the word "command", then hit enter when you see "Command Prompt" show up. :smiley\_cat:
>
> ![a screenshot of the command prompt app showing up as a result of a search](/files/-LxyAsncp1hD9OGB8lzM)

![a screenshot of the command prompt](/files/-LxyAsnexrTbdwlL4DLJ)

## Instructions

After typing each of the commands below, press "enter" to execute it.

Optionally, clear previous output at any time by typing "CLS" and pressing "enter".

### Current User

Print the current user's name:

```bash
whoami
```

### Present Working Directory

Print the current/present working directory:

```bash
cd
```

### List Files in a Directory

List files in the current working directory:

```bash
dir
```

### Navigate and Manage Directories

Change directories (specifying absolute file path):

```bash
cd C:\Users\YOUR_USERNAME\Desktop\ # where YOUR_USERNAME is the name of the user currently operating your local machine
```

> NOTE: if your username has a space in it (e.g. "Sammy Student"), then you may run into issues unless you surround the name of that directory with quotes (e.g. `cd C:\Users\"Sammy Student"\Desktop\`. This usage of quotes applies to any / all files and directories which may have spaces in them, so in general you are encouraged to create new files and directories without any spaces in them, to make life easier on yourself.

Make a new directory:

```bash
mkdir my_folder
```

Remove a directory:

```bash
rmdir my_folder
```

### Manage Files

Change directories (using relative file path):

```bash
cd my_folder # first re-create this directory if it doesn't exist, else this will trigger an error
```

> FYI: Use the command `cd ..` to move "up" one directory relative to the current working directory.

Create one or more files:

```bash
type nul > README.md
type nul > index.html
type nul > my_data.csv
type nul > my_message.txt
```

> CLARIFICATION: yes, `type` is part of the command :smiley\_cat:

Remove/delete a file:

```bash
del index.html
```

Edit and save a file, using a command-line utility provided by your preferred text editor (just choose one of these, depending on which editor you're using):

```bash
code my_message.txt # VS Code text editor, may first require installation of shell commands from the settings
atom my_message.txt # Atom text editor, may first require installation of shell commands from the settings
```

Print file contents:

```bash
type my_message.txt
```

Move a file to target location:

```bash
move C:\Users\YOUR_USERNAME\Desktop\my_folder\my_message.txt C:\Users\YOUR_USERNAME\Desktop
```

> FYI: If you are into maximum efficiency, press "tab" to auto-complete file paths so you don't have to type the whole thing. :smiley\_cat:

Copy a file:

```bash
xcopy C:\Users\YOUR_USERNAME\Desktop\my_message.txt C:\Users\YOUR_USERNAME\Desktop\my_folder
```

Copy contents of a file into the clipboard for pasting:

```bash
type C:\Users\YOUR_USERNAME\Desktop\my_folder\my_message.txt | clip
# ... then just paste as you normally would after copying some text
```

### Further Exploration

Optionally explore additional command-line interfaces, if you're curious.

#### Internet Computing

Trace the route traveled by a network request:

```bash
tracert google.com # stop after a few seconds if necessary by pressing: control + c
```

Time the duration of a network request:

```bash
ping google.com # stop after a few seconds if necessary by pressing: control + c
```

Download the [cURL](https://curl.haxx.se/download.html) utility if necessary, then request the contents of a webpage:

```bash
curl google.com
curl http://www.google.com
curl https://raw.githubusercontent.com/prof-rossetti/intro-to-python/master/data/products.json
```

You may need to execute these commands from within the downloaded directory. See ["Installing cURL on Windows"](http://stackoverflow.com/questions/9507353/how-do-i-install-set-up-and-use-curl-on-a-windows) for more support.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://prof-rossetti.gitbook.io/intro-to-python/exercises/command-line-computing/windows-command-prompt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
