Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

splitコマンドで指定サイズでファイルを分割する

「split」コマンドは指定サイズでファイルを分割する便利ツールです。
ネットワーク越しで更新ファイルを送りたいが、送信側端末に制約がある状況*1では中々有用です。

実際のところ

255バイトごとにファイルを分割する場合、-bオプションをつかいます。

$ split -b 255 search.html

ファイル名は特に指定しないとxaa,xabといった命名規則で名前がつきます。

$ head xa?
==> xaa <==
<!doctype html>
<html>
  <head>
    <title>Search</title>
  </head>
  <body>
    <div id="buttons">
      <label> <input id="query" value='cats' type="text"/><button id="search-button" disabled onclick="search()">Search</button></label>
    </div>
    <di
==> xab <==
v id="search-container">
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="./auth.js"></script>
    <script src="./search.js"></script>
    <script src="https://apis.google.com/js/clie
==> xac <==
nt.js?onload=googleApiClientReady"></script>
  </body>
</html>

行ごとに分割する

shuzo-kino.hateblo.jp

参考もと

  • man split

*1:オレオレFTPクライアントとか、低性能の組み込み端末とか