# open last command in the editor with fc

Some time you have a long command and you want to edit multiple word in it. for example: `$ cat foo.txt | grep foo | grep -v bar > foo_output.txt`

Say you want to execute this 5 times and each replacing `foo` and `bar` with something else.

for that you can use the `fc` command.

```
$ fc
```

It will open a text editor (vim for me. I'm guessing it will look at $EDITOR env variable).\
After that you can edit or duplicate the line easily. Each line will be treated as a single command.

You can as well do something like

```
$ fc foo=baz
```

It will replace all instance of `foo` in the command and replace it with `baz`


---

# 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/open-last-command-in-the-editor-with-fc.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.
