docx-shell-parse
What it does
This skill shows the basic steps for reading .docx files with standard shell tools. It is for people who need quick text from Word files in limited setups.
When to use it
- ✓When Python libraries for Word files are not installed on my computer.
- ✓When I need quick text extraction without installing dependencies.
- ✓When I am working in a container or minimal system with few tools.
Skill link
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-shell-parse/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Get me the text of this Word document. I cannot install libraries here, so please use the shell.”
5 new skills a week. 1 minute to read.
How it works
The AI confirms the file exists, unzips the main document XML, removes the tags and blank lines, and can save the text to a file.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
DOCX Shell Parsing Workaround
When you need to read content from Microsoft Word (.docx) files but python-docx or similar libraries are unavailable, use this shell-based approach to extract text reliably.
When to Use
- Python environment lacks
python-docxor similar libraries - You need quick text extraction without installing dependencies
- Working in constrained environments (containers, minimal images, etc.)
Core Technique
DOCX files are ZIP archives containing XML files. Extract and parse the main document XML:
unzip -p filename.docx word/document.xml | sed -e 's/<[^>]*>//g'
Step-by-Step Instructions
1. Verify the DOCX file exists
ls -la document.docx
2. Extract raw XML content
Use unzip -p to pipe the document.xml content directly to stdout:
unzip -p document.docx word/document.xml
3. Strip XML tags from content
Pipe through sed to remove all XML tags:
unzip -p document.docx word/document.xml | sed -e 's/<[^>]*>//g'
4. Clean up whitespace (optional)
For cleaner output, remove excessive whitespace and newlines:
unzip -p document.docx word/document.xml | \
sed -e 's/<[^>]*>//g' | \
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | \
sed -e '/^$/d'
5. Save extracted text to file
unzip -p document.docx word/document.xml | \
sed -e 's/<[^>]*>//g' > output.txt
Complete Shell Function
Add this reusable function to your scripts:
parse_docx() {
local file="$1"
if [ ! -f "$file" ]; then
echo "Error: File not found: $file" >&2
return 1
fi
unzip -p "$file" word/document.xml 2>/dev/null | \
sed -e 's/<[^>]*>//g' | \
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | \
sed -e '/^$/d'
}
# Usage: parse_docx document.docx
Limitations
- Does not preserve formatting, images, or tables structure
- May include some residual XML entity references
- Works best for simple text extraction needs
- DOCX must be a valid Office Open XML format
Verification
Confirm extraction worked by checking output:
parse_docx document.docx | head -20
Alternative: Extract to Temporary Directory
For more complex parsing needs:
tmpdir=$(mktemp -d)
unzip document.docx -d "$tmpdir"
cat "$tmpdir/word/document.xml" | sed -e 's/<[^>]*>//g'
rm -rf "$tmpdir"
FAQ
Which part of the Word file holds the text?
The main content is in the word/document.xml file inside the archive.
Are blank lines removed?
The optional cleanup step removes extra whitespace and empty lines.
Can I save the result?
Yes, the guide shows how to write the extracted text to a text file.
Details
Original description by the author
Extract text from DOCX files using shell commands when python-docx is unavailable
repo: HKUDS/AgentPilot
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12870
- License
- MIT
- Updated
- 11/1/2026
Comments
- …
More skills from this repository
agentpilot
7.8kHelps your agent improve a project step by step by preparing a task and running the AgentPilot loop that proposes, tests and scores changes.
openspace
7.8kHelps your agent set up OpenSpace, a tool that stores and fetches agent skills, and connect it to your AI app through MCP.
rsi-arena
7.8kHelps your agent set up and run standard AI benchmark tests, such as AIME and Terminal-Bench, to compare different improvement methods.
experiment-guide
7.8kHelps your agent plan small experiments, read their results and record findings while it investigates how to improve a program.
Similar skills
feishu-doc
394kHelps your agent read, create, and edit Feishu cloud documents, including text, images, and tables, using the document tool.
feishu-drive
394kLets your agent browse, organize, and comment on files in a Feishu cloud folder that has been shared with the bot.
feishu-perm
394kHelps your agent check and change who can access a Feishu file, choosing the smallest permission that meets your request.