find: missing argument to `-exec'
时间: 2024-04-29 14:01:47 浏览: 255
This error message occurs when the `find` command is used with the `-exec` flag, but no command is provided to execute. To fix the error, you need to provide a command to execute along with the `-exec` flag. For example:
```
find . -type f -name "*.txt" -exec cat {} \;
```
In this example, the `cat` command is executed on each file that matches the criteria specified by `find`. The `{}` placeholder is replaced by the filename of each file found by `find`. The `\;` at the end of the command tells `find` that the command for each file is complete.
相关问题
find missing argument to -exec
引用和中描述了在使用find命令时出现"find: missing argument to '-exec'"的问题。这个问题通常是由复制和粘贴命令时包含不可见字符导致的。复制的命令中可能包含了空格、换行符或其他不可见字符,这会导致find命令无法正确解析命令参数。解决这个问题的方法是手动输入命令而不是复制粘贴,确保命令中不包含任何不可见字符。所以,解决这个问题的方法是手动输入命令而不是复制粘贴,确保命令中不包含任何不可见字符。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [find:用终端UI包装find(1)](https://download.csdn.net/download/weixin_42131618/18794954)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [maven install 命令提示Missing argument for option: f问题](https://blog.csdn.net/wengkevin/article/details/107281067)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
shell find: missing argument to `-exec'
这个错误通常是因为在使用 `find` 命令的 `-exec` 参数时,没有正确地指定要执行的命令。请检查你的命令中是否正确地使用了 `{}` 和 `;`。`{}` 表示当前 `find` 命令搜索到的文件名,而 `;` 表示命令的结束。例如,正确的使用方式是:
```
find /path/to/search -name "*.txt" -exec rm {} \;
```
这个命令会在 `/path/to/search` 目录及其子目录中查找所有以 `.txt` 结尾的文件,并将它们删除。请注意,在使用 `-exec` 参数时,命令最后必须以 `\;` 结尾,否则会出现 `missing argument to '-exec'` 错误。
阅读全文