Monday 17 June 2013

Splitting, compressing and encrypting files before transfering to others ::: LINUX tricks :::

We all at some point have had to deal with transferring large files across computers. The obvious method is to compress it before sending. For extremely large files we can create a multi-part archive using the following commands.
  • First of all, create a zip archive using
    $ zip -re <compressed_file_name.zip> <file1> <dir1>
    The -r switch allows you to add directories to the archive.
    The -e switch allows encryption, where the program asks you to enter a passphrase that needs to be entered by the recepient in order to extract the archive.
  • Now split the archive into multiple parts with
    $ split --bytes=1K <compressed_file_name.zip> <PREFIX>
    Here, - -bytes=1K specifies that we want parts that are at most 1K bytes in size.
    PREFIX is any user string… For example, if the PREFIX is given as “split_”, then the files that are created will be named split_aa, split_ab, split_ac, etc.
  • On the receiving side, you can extract the multipart zip archive with
    $ cat split_* > my_compressed_file.zip
    Where, “split_” was the PREFIX that the person who created the archive specified.
    Then, extract the whole zip file as follows.
    $ unzip my_compressed_file.zip

No comments:

Post a Comment