Getting ready

This recipe is going to take into account a few interesting things:

  • Bash can't do everything well
  • Other utilities exist (for example, bc)
  • We can create our own in another language like C
  • Creating a tarball
Sometimes, on small embedded systems, Python might not be available, but Bash (or a close relative) and C are. This is where being able to perform math without extra programs (that may not be available) can come in handy!

We will use the following command to make sure that we have all of the utilities installed for this experiment:

$ sudo apt-get install -y bc tar

Now, we need to create a tarball called archive.tar.gz:

$ dd if=/dev/zero of=empty.bin bs=1k count=10000$ tar -zcvf archive.tar.gz empty.bin$ rm empty.bin

We realize ...

Get Bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.