Mission
Many functional programming learning resources will teach you to write functional code, but it's often highly indirect, deeply abstracted, requires understanding complex relationships between custom library calls, and doesn't represent the reality of how people actually write JavaScript.
The goal of this workshop is to create realistic problems that can be solved using terse, vanilla, idiomatic JavaScript.
Bzip2 is used to compress a file in order to reduce disk space, it is quite popular in Linux and UNIX operating systems for this reason. Bzip2 has been around since the late 1990s and is still widely used today. It may be preferable over gzip as it can produce smaller compressed files, at the cost of additional memory and processing time.
Compress a single file
bzip2 file.txt
This will compress file.txt
and create file.txt.bz2
, note that this will remove the original file.txt
file.
Compress multiple files at once
zip2 file1.txt file2.txt file3.txt
This will compress all files specified in the command, note again that this will remove the original files specified by turning file1.txt
, file2.txt
and file3.txt
into file1.txt.bz2
, file2.txt.bz2
and file3.txt.bz2
Compress a single file and keep the original
bzip2 -c file.txt > file.txt.bz
You can instead keep the original file and create a compressed copy.
The -c
flag outputs the compressed copy of file.txt
to stdout
, this is then sent to file.txt.bz2
, keeping the original file.txt
file in place.
The version of bzip2 which is currently the latest available as of this writing also has the -k
option which keeps the original file, so alternatively you could also run the below command to get the same result.
bzip2 -k file.txt
Decompress a bzip2 compressed file
bzip2 -d file.txt.bz2
# OR
bunzip2 file.txt.bz2
To reverse the compression process and get the original file back that you have compressed, you can use the bzip2
command itself or bunzip2
which is also part of the bzip2
package.
Both of these commands will produce the same result, decompressing file.txt.bz2
to file.txt
, removing the compressed file.txt.bz2
file.
Similar to example 3, it is possible to decompress a file and keep the original .bz2 file as below.
bunzip2 -c file.txt.bz2 > file.txt
# OR
bunzip2 -k file.txt.bz2
List compression information
[root@centos ~]# bzip2 -v linux-3.18.19.tar
linux-3.18.19.tar: 6.015:1, 1.330 bits/byte, 83.37% saved, 580761600 in, 96552670 out.
With the -v
or –verbose flag we can see useful information regarding the compression ratio of a file, which shows us how much disk space our compression is saving. Additional ‘v’ flags can be added for more in depth information.
You can issue the following query from the command line:
mysql -uUSER -p -e 'SHOW VARIABLES WHERE Variable_Name LIKE "%dir"'
Output (on Linux):
+---------------------------+----------------------------+
| Variable_name | Value |
+---------------------------+----------------------------+
| basedir | /usr |
| character_sets_dir | /usr/share/mysql/charsets/ |
| datadir | /var/lib/mysql/ |
| innodb_data_home_dir | |
| innodb_log_group_home_dir | ./ |
| lc_messages_dir | /usr/share/mysql/ |
| plugin_dir | /usr/lib/mysql/plugin/ |
| slave_load_tmpdir | /tmp |
| tmpdir | /tmp |
+---------------------------+----------------------------+
Run the below command on terminal to see the contents of a tar.gz
file without extracting it:
tar -tf filename.tar.gz