Ok, that’s a simple one, but it’s always nice to have a quick syntax remainder. So, here’s the best way to compress a whole directory under Linux/UNIX using a shell prompt.
This technique is often used to backup files or to move data using a compressed archive. The GNU tar command is best for this work. This command does two things for you:
You need to use the tar command as follows:
tar -zcvf archive-name.tar.gz directory-name
With the arguments,
For example, you have directory called /home/sm2g/stuff and you would like to compress this directory then you can type tar command as follows:
tar -zcvf backup-2017.tar.gz /home/sm2g/stuff
The above command will create an archive file called backup-2017.tar.gz in current directory. Now, eventually you’ll want to restore your archive. Just use following command (it will extract all files in current directory):
tar -zxvf backup-2017.tar.gz
With,
If you wish to extract files in particular directory, for example in /tmp then you need to use following command:
tar -zxvf backup-2017.tar.gz -C /tmp
cd /tmp
ls -lhart
So you need to convert a bonch of FLAC files to mp3 and your best search engine only recommands you online file converters that nobody trusts ore require a paid subscription to work. Don't worry, *there's always a way*, and even better, a true ***hacker style*** way to achieve this! This procedure works for MacOS through Brew, but you should b... Read more
20 Feb 2019 - less than 1 minute readHere's a small script to open a JavaScript interface to interact with an IoT device. This interface can then be easily incorporated in a larger Blockchain project with real tangible everyday life objects. I'll cover the Blockchain aspect of this project in another article, focusing on *Hyperledger*. The IoT device I'll be using for this project... Read more
20 Aug 2017 - 2 minute readHere's a small script to compress JPEG images in a folder. Useful to save a few kilobytes of bandwith when serving images from your website. I might improve this script in the future to include more compression tools and/or file extensions. ```bash #!/bin/bash for f in *.jpg *.JPG *.jpeg *.JPEG do echo -en "Converting ${f} ... " kb_or... Read more
20 Jul 2017 - less than 1 minute read