ワードシェル芸?の方法。

Tue Apr 22 00:33:46 JST 2014 (modified: Sun Oct 1 10:50:27 JST 2017)
views: 1268, keywords:CLI,docx,シェル芸,エクシェル芸,ワードシェル芸 この記事は最終更新日が7年以上前のものです。

もう、やり方だけ。環境はUbuntu。hxselectで要素を指定するときに、コロンをエスケープするというのでちょっとはまった。

###docxことzipファイルの中はこんな感じ。###
   ###文章の内容はword/document.xml###
   ###画像はjpegがそのまま入っている###
   Archive: self_introduction.docx
    Length Date Time Name
   --------- ---------- ----- ----
    1871 1980-01-01 00:00 [Content_Types].xml
    590 1980-01-01 00:00 _rels/.rels
    1484 1980-01-01 00:00 word/_rels/document.xml.rels
    4835 1980-01-01 00:00 word/document.xml
    1789 1980-01-01 00:00 word/footnotes.xml
    1783 1980-01-01 00:00 word/endnotes.xml
    21556 1980-01-01 00:00 word/media/image1.jpeg
    7561 1980-01-01 00:00 word/theme/theme1.xml
    4193 1980-01-01 00:00 word/settings.xml
    49341 1980-01-01 00:00 word/stylesWithEffects.xml
    48475 1980-01-01 00:00 word/styles.xml
    1021 1980-01-01 00:00 docProps/app.xml
    3484 1980-01-01 00:00 word/fontTable.xml
    8773 1980-01-01 00:00 word/numbering.xml
    871 1980-01-01 00:00 word/webSettings.xml
    713 1980-01-01 00:00 docProps/core.xml
   --------- -------
    158340 16 files
   ###おりゃ###
   ueda@remote:~$ unzip -p self_introduction.docx word/document.xml | hxselect 'w\\:t' | sed 's;</w:t>;&\\n;g'
   <w:t>自己紹介</w:t>
   <w:t xml:space="preserve"> </w:t>
   <w:t>【氏名】漢字)上田 隆一</w:t>
   <w:t xml:space="preserve">    ローマ字)</w:t>
   <w:t>Ryuichi Ueda</w:t>
   ###画像はふつうに抽出###
   ueda@remote:~$ unzip self_introduction.docx word/media/image1.jpeg
   Archive: self_introduction.docx
    extracting: word/media/image1.jpeg 

以上。わーどうしましょう。

ノート   このエントリーをはてなブックマークに追加 
 

prev:unzip -p で真のエクシェル芸が完成したような気がする。 next:Word(docx)用sedを作ってしもうた。

やり散らかし一覧

記事いろいろ