Home / Blog Menu ↓

Blog: #unix

Links #4


Reply via email or office hours

Came across fsql, which does SQL-like filesystem queries (an intriguing idea):

fsql SELECT name FROM ~/Desktop, ~/Downloads WHERE name LIKE %csc%

fsql SELECT all FROM ~ WHERE file IS dir

fsql "name, size, time FROM . WHERE name LIKE %.js AND time > 'Apr 01 2017 00 00'"

fsql "FROM $GOPATH WHERE name = main.go AND (size >= 10.5kb OR size < 100)"

I like it.


Reply via email or office hours

Some small scripts

Migrating to Day One has resurrected my efforts to scan and transcribe my older paper journals. As I’ve been doing this, I’ve run into the need for a couple small shell scripts to automate things.

On several of these journals I’m scanning the full two-page spread because the whole journal fits on the scanner platen, which means splitting the resulting image out into two (one for each page). Splitimage uses ImageMagick to do that nicely. There’s some overlap, but for a fully automated solution it’s not bad, and it saves me a lot of time cropping.

I prefer taking these split images and renaming them sequentially using something more meaningful (“journal-2009.005.jpg” rather than “IMG_0034.JPG”, for example). I used to do this with OS X’s Automator tool, and it works quite well, but I wanted a quick command-line tool to speed things up. Enter dub, a zsh script that simplifies the batch renaming process. Now I can just type:

dub journal-2009.X.jpg *.JPG

And then it’s just a matter of dumping them into Unbindery and transcribing them.


Reply via email or office hours

Unix date magic

The Unix date command has a cool feature I didn’t know about (hat tip to Dave C. for his comment about it on Dr. Drang’s blog). Turns out you can add multiple -v options to adjust dates — for example, to get the date of last Friday:

$ date -v -fri
Fri Sep 21 ... 2012

Or next Thursday:

$ date -v +thu
Thu Sep 27 ... 2012

Or the next Tuesday after two weeks from today:

$ date -v +2w -v +tue
Tue Oct 2 ... 2012

Or thirty seconds from now:

$ date -v +30S

Or five hours ago:

$ date -v -5H

Or ten years, a month, and three days from now (and no, I have no idea why you’d use something like that):

$ date -v +10y -v +1m -v +3d
Thu Oct 27 ... 2022

And so on.


Reply via email or office hours

Vim-fu

Vim has a steep learning curve, but it’s worth it. Here’s a cheat sheet of sorts showing some of the more useful commands (I put it together for a presentation at work):

There’s still a lot more to Vim, of course. And by a lot I mean a huge, massive mountain of things. Our goal here was to introduce some of the basics of Vim and provide a foundation for learning more. :help is your friend.


Reply via email or office hours