Example: Extract a File from tar.gz editTo work with a gzipped tar file:
#! /bin/env tclsh package require tar set chan [open myfile.tar.gz] zlib push gunzip $chan set data [::tar::get $chan some_file_in_tarball -chan] close $chan
Example: Compress to tar.gz edit
#! /bin/env tclsh package require tar set chan [open myfile.tar.gz w] zlib push gzip $chan tar::create $chan list_of_files -chan close $chan
[mrcalvin] - 2018-05-29 23:38:45The channels should be opened in binary mode, either by passing wb and rb, respectively, or setting fconfigure -translation binary explicitly. Otherwise, the above examples will fail in unexpected ways.