---
title: "用相同檔名 + 前綴來備份檔案"
description: "注意：其實你可以在任何指令中使用 !#:1，因為那代表傳給指令的最後一個參數。"
canonical: https://oozou.com/til/back-up-a-file-with-same-name-prefix-42
locale: zh-Hant
date: 2020-10-13
topic: shell
---

# 用相同檔名 + 前綴來備份檔案

> 注意：其實你可以在任何指令中使用 !#:1，因為那代表傳給指令的最後一個參數。

Published: 2020-10-13 · Topic: [shell](https://oozou.com/zh-Hant/til-topics/shell) ([markdown](https://oozou.com/zh-Hant/til-topics/shell.md))

```shell
$ cp todo.txt !#:1.bak
cp todo.txt todo.txt.bak
```

注意：其實你可以在任何指令中使用 *!#:1*，因為那代表傳給指令的最後一個參數。

更新：現在在 zsh 也能用了

---

Contact OOZOU: hello@oozou.com · +66 2544 0000 · https://oozou.com/zh-Hant/contact

More for AI agents: https://oozou.com/llms.txt · every page has a markdown twin at its URL plus ".md"
