Code and comments

Practical and theoretical aspects of software development

Archive for the ‘how-to’ Category

Using find and grep.

leave a comment »

Back in August of last year, for one of the first posts on my brand-new blog, I put up the slides from a lunch-time presentation that I gave on find, grep, sed, and awk. I put it up so that it would be available as reference to those that attended the talk, even though the slides weren’t designed for stand-alone use, and slides make a poor Internet reference.

Given the surprising popularity of that post, it seemed reasonable to repackage the information in a format that is more fitting for a blog post.

find and grep are incredibly powerful. But many never learn a fraction of what they can do. Did you know that grep can print the surrounding lines? Or that you can search for files based on permissions? Here’s a collection of examples that might expand your notion of what can be done with find and grep.

Read the rest of this entry »

Written by Eric Wilson

January 31, 2012 at 12:15 pm

Posted in how-to

Tagged with , , ,

My first five Lucene mistakes

with 4 comments

Lucene logo

I’ve been learning my way around Lucene, the popular Java open source information retrieval software library, lately. Which is to say, I’ve been making mistakes with Lucene.

Much of the time spent with any new technology is in making mistakes, discovering mistakes, and correcting mistakes. An inexperienced programmer would view these mistakes as impediments to progress. It’s far more sensible, and more encouraging, to view these mistakes as the evidence of progress.

With that in mind, I’ll have no shame in sharing my newbie Lucene blunders, with hopes of helping someone that hasn’t yet had the opportunity to fail in all of these ways. Read the rest of this entry »

Written by Eric Wilson

December 14, 2011 at 12:08 pm

Posted in how-to

Tagged with , , ,

The 8 most useful SVN commands

with 2 comments

SubversionI love the command line, and it is my primary interface for version control. When using Subversion, I appreciate the advantages of TortoiseSVN and Subclipse, and I use them on particular occasions. But the speed and precision offered at the CLI are too much of an advantage for any SVN user to ignore.

Some of you are snickering already. “Subversion? It’s almost 2012, past time to move to Git or Mercurial.” Sure, and we’ve all left Java behind, and spend our days coding in Clojure or Scala. The fact is that if you don’t work at a startup, you are unlikely to actually use a DVCS at work, so Subversion is still relevant to more developers than any other version control system, and will be for the next five years, regardless of how you feel about that.

If you are one of those that uses Subversion, read on, and I’ll detail the commands that you should know and use regularly. Read the rest of this entry »

Written by Eric Wilson

December 8, 2011 at 6:50 am

Posted in how-to

Tagged with , ,

Command-line keyboard shortcuts for Bash

with 3 comments

I love keyboard shortcuts, and I do my best to incorporate them with every GUI application that I use regularly. I’ve been comparatively negligent in learning keyboard shortcut for the command-line applications, as it seems less advantages. After all, there’s no need to reach for the mouse, what are we hoping to save?

Nevertheless, there are real efficiencies out there, and here are my favorite Bash shortcuts. Read the rest of this entry »

Written by Eric Wilson

October 25, 2011 at 5:39 am

Posted in how-to

Tagged with , , ,

Viewing multiple files with less

leave a comment »

When you want to see the contents of a text file in unix, the first two things to come to mind are cat and less. I choose cat when the files are small, but the pagination and navigation in less makes it the better choice most of the time.

Suppose you find a directory with five files that are unknown to you. Printing the contents of all five is easy enough with cat and a pipe:

$ ls | xargs cat

 
But if you have five files, chances are you don’t just want everything scrolling past you. So we try:

$ ls | xargs less

 
Hmm … when you get to the bottom of file1.txt we find the message (END) - Next: file2.txt. What to do?

As always, the answer is in the man page: :n for next file, :p for previous file.

Of course, this isn’t only useful when piping input into less, it also works when specifying multiple arguments:

$ less file1.txt file2.txt file3.txt

 

Written by Eric Wilson

October 17, 2011 at 2:26 pm

Posted in how-to

Tagged with , ,

Typesetting vertical arithmetic in LaTeX using xlop

with 2 comments

If the question involves mathematical typesetting, then you can be sure that the answer is LaTeX. But if you are off the beaten path, LaTeX can be both the solution and a new problem.

I was interested in typesetting some elementary-school style vertical arithmetic problems. You know, like:

  28
+ 15
----

 
Except with better readability.

Read the rest of this entry »

Written by Eric Wilson

September 19, 2011 at 12:29 pm

Posted in how-to

Tagged with ,

Getting started with The Little Schemer

with 4 comments

Every programmer should read The Little Schemer (pdf) at some point. It doesn’t take long to read, and I hope to provide a review of it soon. For now, I hope to explain how to get started practically with Scheme, as used in this book, since these details are hard to find.

Read the rest of this entry »

Written by Eric Wilson

September 1, 2011 at 9:52 am

Posted in how-to

Tagged with , , ,