---
title: "用相同文件名 + 前缀来备份文件"
description: "注意：其实你可以在任何命令中使用 !#:1，因为它代表传给该命令的最后一个参数。"
canonical: https://oozou.com/til/back-up-a-file-with-same-name-prefix-42
locale: zh-Hans
date: 2020-10-13
topic: shell
---

# 用相同文件名 + 前缀来备份文件

> 注意：其实你可以在任何命令中使用 !#:1，因为它代表传给该命令的最后一个参数。

Published: 2020-10-13 · Topic: [shell](https://oozou.com/zh-Hans/til-topics/shell) ([markdown](https://oozou.com/zh-Hans/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-Hans/contact

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