TAR: Speed up compression on multicore systems

This is a little tip to speed up creating tar archive.

By default tar using gzip to compress and if you look at htop output, gzip use only one cpu.

Tar have an argument –use-compress-program, which allow us to set another gzip-ing program.

The most known mutlithreading gzip alternatives is pigz.

So, the tar usage should looks like:

tar --use-compress-program=pigz -cf ...

Under the cut you found the compression time difference between gzip and pigz Continue reading

BASH: Tail follows a file until string isn’t matched

The problem seems pretty easy… for the first look.

# Prepare :>/tmp/output.log (sleep 1s; echo "exit on match" >> /tmp/output.log) & tail -n +0 -f /tmp/output.log | sed '/exit on match/{p;q}'

My first reaction was “Wuuuut?”, because tail isn’t react on SIGPIPE.

Continue reading

BASH: Make the same files tree with other extension

… using ‘find’. The issue is making same tree files in other directory with other extension,
in my case is making js-behaviors tree for templates.
Also have a two directories assets/app/dialogs (current directory) and templates/dialogs.
Prepare current directory. Next shell make the same directory tree:
$ find ../../../templates/dialogs/ -mindepth 1 -type d \ -exec sh -c "mkdir -p \${0:27}" {} \;
Continue reading