關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 在 Linux 下分割及合拼檔案

    Posted on January 11th, 2006 Sam Tang No comments

    如果需要將一個體積龐大的檔案分割成細小的檔案,在 Linux 可以用以下方法簡單實現:

    分割檔案
    假如有一個 5MB 的 testing.mp3 檔案,你想分割成每份 1MB 大小的檔案,可以用以下指令:

    split –bytes=1000000 testing.mp3 output

    以上指令設定了分割檔案的大小上限為 1000000 bytes,以及分割好的檔案會以 output 開頭,然後加上分割檔案的順序編號,例如 output00, output01 等。

    合拼檔案
    分割完檔案後當然需要合拼,只要使用以下指令即可:

    cat split1 split2 split3 > output

    以上指令會將 split1, split2, split3 合拼為 output 檔案。如果在目錄內沒有其他檔案是以 output 開頭的話,則可以將以上指令簡化成:

    cat split* > output


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word