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

docx-shell-extract

하는 일

이 스킬은 .docx 파일의 압축을 풀고 표준 명령줄 도구로 마크업을 제거해 읽는 방법을 보여 줍니다. 추가 소프트웨어를 설치하지 않고 Word 텍스트가 필요한 사람에게 맞습니다.

사용하는 경우

  • ✓내 컴퓨터에 python-docx 같은 라이브러리가 없을 때.
  • ✓아무것도 설치하지 않고 Word 파일에서 빠르게 텍스트를 뽑고 싶을 때.
  • ✓제한된 환경이라 셸 도구만 쓸 수 있는 경우.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/docx-shell-extract/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-extract/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분.

작동 방식

.docx 파일은 XML이 들어 있는 zip 압축 파일입니다. AI는 주 문서 XML을 꺼내고, 태그와 빈 줄을 지운 뒤 결과를 일반 텍스트로 저장합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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
자주 묻는 질문

Word 파일이 zip처럼 동작하는 이유는 무엇인가요?

.docx 파일은 문서 내용을 담은 XML 파일들이 들어 있는 zip 압축 파일입니다.

서식과 표가 유지되나요?

이 방법은 마크업을 제거하므로 원래 배치가 아니라 일반 텍스트를 반환합니다.

결과를 저장할 수 있나요?

네, 가이드는 추출한 텍스트를 텍스트 파일로 쓰는 방법을 보여 줍니다.

상세 정보

작성자의 원본 설명

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

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#12867
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬