Zum Inhalt springen
Skillpedia
PDF, Word & Folien7.8k · #12867

docx-shell-extract

Was er macht

Dieser Skill zeigt, wie eine .docx-Datei mit Standardwerkzeugen der Kommandozeile entpackt und ihre Auszeichnung entfernt wird. Er richtet sich an Menschen, die Word-Text ohne zusÀtzliche Software brauchen.

Wann du ihn nutzt

  • ✓Wenn python-docx oder Ă€hnliche Bibliotheken auf meinem Computer nicht verfĂŒgbar sind.
  • ✓Wenn ich schnell einen Textauszug aus einer Word-Datei brauche, ohne etwas zu installieren.
  • ✓Wenn die Umgebung eingeschrĂ€nkt ist und nur Shell-Werkzeuge funktionieren.

Link zum Skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-shell-extract/SKILL.md

Kopiere ihn und fĂŒge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und fĂŒge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum EinfĂŒgen

Nutze diesen Skill, um mir zu helfen: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-shell-extract/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen fĂŒr meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Ich brauche den Text aus dieser Word-Datei und kann keine zusĂ€tzliche Software installieren. Kannst du ihn ĂŒber die Kommandozeile herausholen?”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Eine .docx-Datei ist ein ZIP-Archiv mit XML-Dateien. Die KI entpackt das Haupt-XML-Dokument, entfernt die Tags und Leerzeilen und speichert das Ergebnis als Klartext.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

DOCX Shell Extraction

When to Use This Skill

Use this pattern when you need to read or extract text from Microsoft Word (.docx) files in constrained environments where:

  • The python-docx library is not available
  • You cannot install additional Python packages
  • You need a quick, reliable shell-based solution

Core Technique

DOCX files are ZIP archives containing XML files. The main document content is stored in word/document.xml. You can extract and parse this using standard shell tools.

Step-by-Step Instructions

Step 1: Extract the document.xml content

unzip -p filename.docx word/document.xml

The -p flag pipes the content to stdout without extracting to disk.

Step 2: Strip XML tags to get plain text

unzip -p filename.docx word/document.xml | sed 's/<[^>]*>//g'

This removes all XML tags, leaving the text content.

Step 3: Clean up whitespace (optional)

For cleaner output, add additional sed processing:

unzip -p filename.docx word/document.xml | \
  sed 's/<[^>]*>//g' | \
  sed 's/&[^;]*;//g' | \
  sed 's/^[[:space:]]*//' | \
  sed 's/[[:space:]]*$//' | \
  sed '/^$/d'

This removes:

  • XML tags
  • XML entities (like &amp;, &lt;)
  • Leading/trailing whitespace
  • Empty lines

Step 4: Save to a text file (optional)

unzip -p filename.docx word/document.xml | \
  sed 's/<[^>]*>//g' > output.txt

Complete Example

# Extract text from a Word document
DOCX_FILE="report.docx"
OUTPUT_FILE="report_text.txt"

unzip -p "$DOCX_FILE" word/document.xml | \
  sed 's/<[^>]*>//g' | \
  sed 's/&[^;]*;//g' | \
  sed '/^$/d' > "$OUTPUT_FILE"

echo "Extracted text saved to $OUTPUT_FILE"

Verification

After extraction, verify the content was captured:

# Check if output file has content
if [ -s "$OUTPUT_FILE" ]; then
    echo "Successfully extracted $(wc -l < "$OUTPUT_FILE") lines"
    head -5 "$OUTPUT_FILE"
else
    echo "Warning: Output file is empty"
fi

Limitations

  • This method extracts raw text without formatting
  • Complex layouts, tables, and images are not preserved
  • Some special characters may need additional handling
  • Works best for text-heavy documents

Alternatives to Explore

If this approach fails or the DOCX structure differs:

  • Check for word/document.xml existence: unzip -l filename.docx | grep document.xml
  • Some documents may use word/*.xml with different naming
  • Consider pandoc if available: pandoc filename.docx -t plain
HĂ€ufige Fragen

Warum verhÀlt sich eine Word-Datei wie ein ZIP?

Eine .docx-Datei ist ein ZIP-Archiv mit XML-Dateien, die den Dokumentinhalt enthalten.

Bleiben Formatierung und Tabellen erhalten?

Die Methode entfernt die Auszeichnung und liefert daher Klartext statt des ursprĂŒnglichen Layouts.

Kann das Ergebnis gespeichert werden?

Ja. Die Anleitung zeigt, wie der extrahierte Text in eine Textdatei geschrieben wird.

Details

Originalbeschreibung des Autors

Extract text from DOCX files using shell commands when python-docx is unavailable

repo: HKUDS/AgentPilot

Beliebtheit

GitHub-Sterne
7.8k
Platz im Ranking
#12867
Lizenz
MIT
Aktualisiert
1.11.2026

Ist dieser Skill nĂŒtzlich?

0

Anmelden um abzustimmen.

Kommentare

  • 


Weitere Skills aus diesem Repository

Ähnliche Skills