入门 03
⏱️ 20分钟
文件操作
学习如何使用 OpenClaw 读写文件、批量处理。
学习目标
- 读取文件内容
- 写入和修改文件
- 批量处理文件
读取文件
# 读取整个文件
openclaw read document.txt
# 读取前50行
openclaw read document.txt --limit 50
# 读取代码文件
openclaw read script.py
写入文件
# 写入内容
openclaw write output.txt --content "Hello World"
# 创建新文件
openclaw write notes.md --content "# My Notes"
编辑文件
# 替换文本
openclaw edit config.yaml --old "localhost" --new "127.0.0.1"
实用技巧
让 AI 分析文件:
openclaw read code.py | openclaw "分析这段代码的问题"