Bash has handy brace expansion powers that I've belatedly discovered. $ echo I love hippo{griffs,potamuses,dromes} I love hippogriffs hippopotamuses hippodromes For example, you can quickly diff a file with and without a suffix: $ echo diff .env{,.example} diff .env .env.example Or tail multiple log files: $ echo tail -f /var/log/{messages,secure} tail -f /var/log/messages /var/log/secure Bash … Continue reading Brace expansion to match multiple files in Bash
Category: Unix
Update OpenLDAP SSL certificate on CentOS 6
You may need to update your OpenLDAP SSL certificate, as well as the CA certificate and signing key on a regular basis.
Enable better git diffs on the Mac
git 2.9 brings new features that make reviewing changes easier. Everyone should set these configuration options to enable better git diffs.
Preserve bash history across multiple terminals and sessions
Is it possible to configure the terminal to preserve bash history? Yes, it's easy to configure bash so that it preserves history across sessions and tabs.
Unix command of the day: watch
The project I'm working on right now involve not just Dockerized Rails microservices, Meteor JS, and a data set measured in tens of terabytes, but also a big Bash code base. Bash is a language that makes it easy to shoot yourself in the foot. I have some thoughts on how to write robust, modular, … Continue reading Unix command of the day: watch
libdb2.so.1: cannot open shared object file
I got this error starting a ruby application: /usr/local/rvm/gems/ruby-1.9.3-p547/gems/bundler-1.7.3/lib/bundler/runtime.rb:76:in `require': libdb2.so.1: cannot open shared object file: No such file or directory - /usr/local/rvm/gems/ruby-1.9.3-p547/extensions/x86_64-linux/1.9.1/ibm_db-2.5.11/ibm_db.so (LoadError) An .so is a Linux library, equivalent to a .dll on Windows or a .dylib on Mac. Note that there are two different libraries mentioned. ibm_db.so is present, while libdb2.so.1 is … Continue reading libdb2.so.1: cannot open shared object file
Persistent SSH sessions with screen
Do you ever need to kick off a long-running command while SSHed to a server, but be able to disconnect and reconnect at will? You can do this with screen. Before doing anything, start a screen session: screen When you're ready to put your work on hold, detach the screen: screen -d If you have … Continue reading Persistent SSH sessions with screen
Linux command of the day: banner
banner can be a useful command for setting login and welcome messages (e.g via /etc/profile). $ banner PRODUCTION ###### ###### ####### ###### # # ##### ####### ### ####### # # # # # # # # # # # # # # # # # # ## # # # # # # # # … Continue reading Linux command of the day: banner
The specified bucket is not S3 v2 safe
I ran into this error when running ec2-upload-bundle:The specified bucket is not S3 v2 safe (see S3 documentation for details)This was due to uppercase letters or underscores. Later I also ran into an issue with periods in bucket names which showed up as this error message:ERROR: Error talking to S3: Server.AccessDenied(403): Access DeniedHere is an … Continue reading The specified bucket is not S3 v2 safe
Have bash warn you about uninitialized variables with set -u
By default, Bash treats uninitialized variables the same way as Perl -- they are blank strings. If you want them treated more like Python, you can issue the following command in your bash script: set -u You will then start seeing warning messages like the following: ./my_script.sh: line 419: FOO_BAR: unbound variable Note that this … Continue reading Have bash warn you about uninitialized variables with set -u