Commands by spsneo (1)

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

Validating a file with checksum

Rename files in batch

Delete only binary files in a directory
Please note that binary file checking is NOT perfect. So, use it with caution. It does not delete hidden files whose name has a leading '.' character. And it regards an empty file as a binary file.

bash/ksh function: given a file, cd to the directory it lives
fcd : file change directory A bash function that takes a fully qualified file path and cd's into the directory where it lives. Useful on the commadline when you have a file name in a variable and you'd like to cd to the directory to RCS check it in or look at other files associated with it. Will run on any ksh, bash, likely sh, maybe zsh.

Sort on multiple dis-contiguous keys/fields (can even specify key number/field from the end)
Notes: 1) -n-1 means sort key is the last field 2) -l is important if each separate record is on a new line (usually so for text files) 3) -j tells msort not to create log file (msort.log) in the working directory 4) may need to install msort package. 5) msort does lot more. Check man msort

Downmix from stereo to mono and play radio stream with mplayer
The solution to a year long (and extremely frustrating) problem I've had, caused by the fact that I only have one speaker; this command downmixes the stream to monophonic output, making sure I don't miss any of the music. NOTE: When stream is in .m3u format, a -playlist option is required, as shown below: $ mplayer -af pan=1:0.5:0.5 -channels 1 -playlist radiostream.m3u This command works great with aliases for various channels in .bashrc. Sample below: $ alias radio1='mplayer -af pan=1:0.5:0.5 -channels 1 radio1stream.pls'

Install pip with Proxy
Installs pip packages defining a proxy

Empty a file

Random Number Between 1 And 256
It takes a byte from /dev/random whose source is the kernel entropy pool (better source than other solutions).

log rm commands
Sometimes, it is annoying to find your files or directories missing. If you want to log all the rm commands you can put this in /etc/profile.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: