> For the complete documentation index, see [llms.txt](https://igb.mit.edu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://igb.mit.edu/mini-courses/introduction-to-unix/files/viewing-file-contents.md).

# Viewing File Contents

* `cat`
  * Concatenates two files together, then prints content to STDOUT.
  * Colloquially, it's used to print out the contents of a single file.

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

cat arrayDat.txt
```

* `head`
  * By default, prints the first 10 lines of a file to STDOUT.
  * You can pass the `-n` flag to specify the number of lines to print.

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

# Print the first 10 lines of arrayDat.txt
head arrayDat.txt

# Print the first 5 lines of arrayDat.txt
head -n 5 arrayDat.txt
```

* `tail`
  * By default, prints the last 10 lines of a file to STDOUT.
  * You can pass the `-n` flag to specify the number of lines to print.

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

# Print the last 10 lines of arrayDat.txt
tail arrayDat.txt

# Print the last 5 lines of arrayDat.txt
tail -n 5 arrayDat.txt
```

* `less`
  * Lets you page through a long file or stream of text a.k.a. you can scroll.
  * Exit by pressing `q`

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

# Scroll through the contents of arrayDat.txt
less arrayDat.txt
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://igb.mit.edu/mini-courses/introduction-to-unix/files/viewing-file-contents.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
