Shell programming Archive

Storing file metadata with fnmeta.py


The problem Have you ever named a file something like… main.cpp.GOOD … to indicate a “known-good” copy of `main.cpp`? This simplistic method for storing file metadata is great because it’s filesystem-agnostic – the metadata (e.g. “this is known-good source code”) “follows” the file wherever it goes – from ext3 to FAT32 to NTFS, etc. However, [...]

Adding a dimension to your photos


Have you ever wanted to transform a run-of-the-mill photograph into a complete 3D scene automagically like Jack Black does in this mildly-NSFW 35MiB 2min clip from Enemy of the State? Well too bad — it’s just not possible to ascertain details that are hidden from the camera’s view! You can get pretty close, though, with [...]

Sending data via cellular voice connections with Linux


“A5/1 [the encryption scheme used in most cellular voice calls] has operated unchanged for the last 21 years but it has now reached its cryptographic end-of-life, engulfed by the march of Moore’s Law. However, the operational end-of-life of A5/1 may still be decades away as there are approximately 2 billion GSM subscribers, commanding about 80% of [...]

good.net is fast.com


good.net is a stripped-down file-hosting service (cf. drop.io/sendthisfile.com)1 that has four “new-to-me” features:2 You can earn money when people download your files via their affiliate program. Your audience can access your files via HTTPS. An honest dedication to free speech and free software. You can upload your files via FTP-over-explicit-SSL (FTPES). Their support page doesn’t list [...]

A Bash “edit-in-place” idiom


I use a shell script called `stream.sh` to launch my music player and open a given internet radio station. I use it like this to tune to a local AM station: $ stream.sh 1370 I usually edit small scripts like that with `nano(1)`. Rather than type the entire path to the script when I need [...]

Editing files as root with Emacs and Tramp


Did you know that you can use an existing non-privileged instance of Emacs to open files as root? Yep, Emacs includes a module called TRAMP which can use sudo to read and write files. As is usually the case, I had to work sweat a little to make it work. My problem was that my [...]

Omitting Certain Commands from zsh’s History


I use pwsafe to store passwords on Ubuntu. It’s a *nix command line port of Counterpane’s Password Safe which uses twofish to store passwords in a database file. You can find it in the Ubuntu universe repository. If someone somehow managed to get ahold of my shell’s history file, they’d get a lot of juicy [...]

Determining who acted in two known films


Have you ever seen someone in a movie and thought to yourself “Hey, weren’t they in movie Y too?” This happened to me last night when I was watching ”Casino”. The parking lot attendant from a certain scene looked just like a character from ”Fear and Loathing in Las Vegas”. To the *nix shell, Robin!</Bruce [...]

Saving piped output with less


The problem You’ve piped the lengthy output of some command to your pager, less. As you’re scrolling through the output you realize you’d like to save it to disk. The output took a long time to generate, so you don’t want to re-run the original command just to redirect the output to a file. Your [...]

Recalling a word from the current command line


I often find myself using a command like this to make a backup of a file: cp /etc/slop/gunk.conf /etc/slop/gunk.conf_before_v2_upgrade Since the first portion of the second argument is always the same as the first argument (the green text), it bugged me to have to do tab completion for it. Luckily, zsh and bash provide an [...]