# 在脚本的 shebang 行中使用 LLM

- 原标题：Using LLM in the shebang line of a script
- 类型：教程
- 来源：Simon Willison 博客
- 发布时间：未知（待核验）
- 首次精选：2026-10-29 23:09
- 分级：值得看
- 学习层级：入门
- 主题：[ai-tools-prompting](<https://oplearnx.com/md/topics/ai-tools-prompting.md>)（第 16 位）
- 原文链接：[https://til.simonwillison.net/llms/llm-shebang](<https://til.simonwillison.net/llms/llm-shebang>)
- 本站页面：[https://oplearnx.com/resources/pk\_e1b3ddde9ec1](<https://oplearnx.com/resources/pk_e1b3ddde9ec1>)

## 摘要

这篇 TIL 记录了如何把 LLM 命令行工具写进脚本的 shebang，从而让一段英文（或其他自然语言）文本文件可以直接执行。文中给出的写法是 \#\!/usr/bin/env -S llm -f，保存为 pelican.sh 并用 chmod \+x 赋权后即可运行；额外参数会透传给 LLM，例如用 -m 换模型，加 -x 可只提取响应中的第一个代码块；-f 必须放在最后，因为它接收脚本文件路径。文中还解释了 env 的 -S 选项的必要性，否则 env 会把整行当作一个命令名而报错。适合想把 LLM CLI 嵌入可执行脚本的人参考。

---
来源：LearnMap · 学径（https://oplearnx.com）
