Blog Archives

How to create a video DVD with command line tools

DVDsMaybe you know this scenario: You’ve been invited to a family get-together and you take some videos of the most memorable events. Afterwards a family member comes to you and says: “I’ve seen you recording this and that. Could you give it to me on DVD?”. As a matter of fact, you can easily create a video DVD of any video you have recorded with just a view command lines.
Read the rest of this entry

How to extract video URLs from YouTube

I know there are many tools out there that allow you to download videos from YouTube, like the Video Download Helper for Firefox, even online tools that convert the audio to mp3. The reasons I’m writing this article are a) because sometimes you just need the URL, for example to watch a video with a much less ressource consuming player like VLC or ffplay, b) because sometimes you just want to listen to the audio and save up even more ressources by not decoding the video and c) because I can 😉
Read the rest of this entry

How to make daily backups with rsync and cronjobs

It’s always a good idea to make backups of important data (documents, images, music, etc.), e.g. the worst case for students is to lose data of written reports or theses.
I wanted to make backups of my documents and source codes every day. The backup should be stored on a usb flash drive. But I also wanted to keep deleted files for a couple of days, in case of accidentally deleted files. There are many ways to complete this task, but I decided to use rsync and cronjobs for this purpose. Both tools make the backup process very flexible. It’s very easy to manage the time of the backup process with cronjobs and rsync makes it easy to change the destination (e.g. another folder, device or remote host).
My idea was to add a cronjob to start a bash script which uses rsync to copy the directories and files to the flash drive. But the device names of flash drives changes, if you plug them in a different order. To avoid this problem, I added a udev rule to create a symbolic link every time the flash drive is plugged.
Read the rest of this entry

How to trim strings with bash

If you want to trim a string from or to a certain pattern, you don’t have to invoke cut, sed or awk. You can use the % operator to trim a string from the first or last occurrence of a pattern to the end or the # operator to trim from the beginning to the first or last occurrence of it.
Read the rest of this entry

How to transcode a directory of audio files to AAC with FFmpeg

I recently started to backup my CDs as lossless flac files on my home server. The problem is, my mobile phone cannot play back flac files, so I wrote a little bash script that transcodes a directory of audio files to high quality variable bitrate AAC files that I can play back on my mobile phone. Read the rest of this entry

How to get the top 10 recently used commands

The file .bash_history in a users home-directory saves the recently used commands. You can modify the maximum number of lines that will be stored in .bash_history. You only have to change the value of the global bash variable $HISTFILESIZE. For much more details have a look at the bash man-page.

We use sort, uniq and head to get the top 10 recently used command.
Read the rest of this entry