मुख्य सामग्री पर जाएँ
Skillpedia
PDF, Word और स्लाइड7.8k · #12870

docx-shell-parse

यह क्या करती है

यह स्किल मानक शेल टूल्स से .docx फ़ाइलें पढ़ने के बुनियादी चरण बताती है। यह उन लोगों के लिए है जिन्हें सीमित सेटअप में Word फ़ाइल से जल्दी टेक्स्ट चाहिए।

कब इस्तेमाल करें

  • ✓जब मेरे कंप्यूटर पर Word फ़ाइलों के लिए Python लाइब्रेरी इंस्टॉल न हों।
  • ✓जब मुझे डिपेंडेंसी इंस्टॉल किए बिना जल्दी टेक्स्ट निकालना हो।
  • ✓जब मैं कंटेनर या कम टूल्स वाले सिस्टम में काम कर रहा हूँ।

Skill का लिंक

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

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-shell-parse/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मुझे इस Word दस्तावेज़ का टेक्स्ट चाहिए। मैं यहाँ लाइब्रेरी इंस्टॉल नहीं कर सकता, इसलिए कृपया शेल से निकालिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

AI पुष्टि करता है कि फ़ाइल मौजूद है, मुख्य दस्तावेज़ XML को unzip करता है, टैग और खाली पंक्तियाँ हटाता है, और चाहे तो नतीजा फ़ाइल में सहेजता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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-docx or 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"
अक्सर पूछे जाने वाले सवाल

Word फ़ाइल का टेक्स्ट किस हिस्से में होता है?

मुख्य सामग्री आर्काइव के अंदर word/document.xml फ़ाइल में होती है।

क्या खाली पंक्तियाँ हटाई जाती हैं?

वैकल्पिक सफ़ाई चरण अतिरिक्त स्पेस और खाली पंक्तियाँ हटाता है।

क्या नतीजा सहेजा जा सकता है?

हाँ, गाइड दिखाती है कि निकाला गया टेक्स्ट टेक्स्ट फ़ाइल में कैसे लिखें।

जानकारी

लेखक का मूल विवरण

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

repo: HKUDS/AgentPilot

लोकप्रियता

GitHub स्टार
7.8k
रैंकिंग में स्थान
#12870
लाइसेंस
MIT
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills