# get all line except n last one

with `head -n <negative number>` we can get the output except n lines

example

```
cat a.txt | head -n -1
```

will gives as the content of a.txt except the last one

Let say we have file 1 2 3 4 5, and with grep we want to only get 1 2 3.

we can achive this with ls and grep

```
$ ls | grep 4 -B 100000000 | head -n -1
```

the -B show 100000000 lines before matched line, and the head -n -1 removes the matched


---

# 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://til.yulrizka.com/unix/get-all-line-except-n-last-one.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.
