# Print line at number

To print a line at a given position (say, line 10) within a file, we can use this invocation of `sed`:

```bash
sed '10q;d' file
```

`d` means every line will be removed from the output, except for line 10, where the deletion is short-circuited by quitting `q`. The result is that only line 10 is printed, and the rest of the file isn't processed.

An alternative is:

```bash
sed -n '10p' file
```

It is somewhat more intuitive, using `-n` to avoid printing lines, except for line 10 which is explicitly printed. The drawback is that the entire file is processed. Keep this in mind if performance is a priority.

[Source](https://stackoverflow.com/a/6022431)


---

# 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://notes.eliasnorrby.com/bash/print-single-line.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.
