본문으로 건너뛰기
Skillpedia
PDF, Word, 슬라이드7.8k · #12870

docx-shell-parse

하는 일

이 스킬은 표준 셸 도구로 .docx 파일을 읽는 기본 단계를 보여 줍니다. 제한된 환경에서 Word 파일의 텍스트를 빠르게 얻어야 하는 사람에게 맞습니다.

사용하는 경우

  • ✓내 컴퓨터에 Word 파일용 Python 라이브러리가 설치되어 있지 않을 때.
  • ✓의존성을 설치하지 않고 빠르게 텍스트를 추출해야 할 때.
  • ✓도구가 적은 컨테이너나 최소 시스템에서 작업하는 경우.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-shell-parse/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 Word 문서의 텍스트를 가져와 주세요. 여기서는 라이브러리를 설치할 수 없으니 셸을 사용해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 파일이 있는지 확인하고, 주 문서 XML의 압축을 풀고, 태그와 빈 줄을 제거한 뒤 텍스트를 파일로 저장할 수 있습니다.

기술 내용 (원본 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
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬