# Editing the Unix Tree

**Make sure to run all of the copy commands below, as we'll be using files from the Ostrom server later in the course.**

* `mkdir`
  * This command name stands for "make a directory".
  * It creates a new folder (or directory). If no path is specified, the new directory is created in the current directory.

<pre class="language-bash"><code class="lang-bash"><strong># start in your home directory
</strong><strong>cd ~
</strong><strong>
</strong><strong># create a directory named "unixclass"
</strong><strong># with a subdirectory named "testdir"
</strong>mkdir unixclass
mkdir unixclass/testdir

# change current directory directly to "testdir"
cd unixclass/testdir 

# go to the parent directory (i.e. unixclass)
# and print the working directory
cd ..
pwd
</code></pre>

* `touch`
  * This command creates an empty file with the given name.

```bash
# Go to /home/<your username>/unixclass
cd ~/unixclass

# Create an empty file named "hello.txt"
touch hello.txt

# List the files in the directory to verify that worked
ls
```

* `cp` and `mv`
  * These commands stand for "copy" and "move," respectively.
  * They copy / move files and directories to the specified location.
  * Wildcards symbols such as "\*" or "?" are commonly used to copy multiple files with a single command.
    * The symbol "\*" stands for any number of alphanumeric characters.
    * The symbol "?" stands for a single alphanumeric character.

```bash
# Start in ~/unixclass
cd ~/unixclass

# copy the file named arrayDat.txt into your unix_class directory
cp /net/ostrom/data/dropbox/arrayDat.txt .
ls
```

```bash
# copy all the files with suffix "array”
# into the current directory 
cp /net/ostrom/data/dropbox/array* .
ls

# copy any file whose extension is "txt" 
cp /net/ostrom/data/dropbox/*.txt .
ls

# copy all files
cp /net/ostrom/data/dropbox/* .
ls
```

* `rmdir` and `rm`
  * `rmdir` **only** removes empty directories, `rm` removes both directories and files.
  * `rm` needs `-r` flag to remove directories.

```bash
# Start in ~/unixclass
cd ~/unixclass

# Create a temporary directory
mkdir trash

# create copies of arrayDat.txt in the temporary directory
cp arrayDat.txt trash/arrayDat1.txt
cp arrayDat.txt trash/arrayDat2.txt
cp arrayDat.txt trash/arrayDat3.txt
cp arrayDat.txt trash/arrayDat4.txt

ls trash
```

```bash
# Try to delete the directory with `rmdir`
rmdir trash

# Try to delete the directory with `rm -r`
rm -r trash
```


---

# 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://igb.mit.edu/mini-courses/introduction-to-unix/the-unix-shell/using-the-unix-shell/editing-the-unix-tree.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.
