The Command Line Utility “jot”

My good friend Kenny Chiou, a physical anthropology graduate student at Washington University in St. Louis, sent me a handy script he wrote to generate a series of number in R after seeing my previous blog post. Talking to him reminded me of the command line utility jot, which seems to be only on Macs and a subset of Unix machines. It’s a handy one to have in your toolkit, so here’s a brief tutorial.

jot with one number after it gives you a sequence up to the supplied number starting with one:

$ jot 5

Adding a second number lets you change the start, so here are five numbers starting with 50:

$ jot 5 50

If you use it as the input for a for loop, you can embed your number series in echoed text:

$ for i in `jot 5 50`; do echo "img${i}.jpg"; done;

which actually can be more simply done using the -w flag and sprintf string formatting:

$ jot -w "img%d.jpg" 5 50

And since it uses sprintf formatting, you can add leading zeros simply by changing the %d to, say %03d for three digits:

$ jot -w "img%03d.jpg" 5 50

I wrote a script to rip off Kenny’s idea duplicate the functionality of Kenny’s script using pure bash. It gets passed parameters, computes the total length of the desired sequence, and then calls jot similar to the last example command above. You call it like this:

get_sequence -b beginning -e ending -p prefix -s suffix [-d digits]

$ ./get_sequence -b 17 -e 24 -p "img" -s ".png"

Here’s the full script, quick and dirty and untested. It could be useful to stick in your bin/ directory. All credit to Kenny for the inspiration and algorithm.

# Arguments = -b beginning -e ending -p prefix -s suffix [-d digits]

# Default values

while getopts b:e:p:s:d: opt; do
	case $opt in
		b) begin=$OPTARG;;
		e) ending=$OPTARG;;
		p) prefix=$OPTARG;;
		s) suffix=$OPTARG;;
		d) digits=$OPTARG;;

total=`expr $ending - $begin`
total=`expr $total + 1`

jot -w "$prefix%0${digits}d${suffix}" $total $begin;


Edit: Aaannnnd thanks to Kenny for catching a bug in the script.

Preparing an Academic CV in LaTeX using Mendeley

Applying for grants recently, I found it high time to update my curriculum vitae. I looked at the folder of Word .docs with names like Bergey_CV_2010_07_01.doc and CMB_CV_20111012_final.doc and CMB_CV_20111012_final_FINAL.doc and despaired. Guilt over my unideal system grappled with inertia and laziness, but finally I decided to make a change. I’d been meaning to start making more use of LaTeX, the document preparation system anyway.

Why LaTex? In a nutshell, because it’s easier to update plain text files than Word documents. You type up your CV’s text with mark-up, or special character combos that tell the software how to format your text. Then you can compile it straight to PDF format. Updating takes seconds, as do formatting changes like different margin sizes. You can easily comment out a section to temporarily delete it. LaTeX files also lend themselves to version control, which can keep track of changes for you, though that is the subject of a later post.

I stole very heavily from some online examples (linked to below), as I hope that anybody looking to try LaTeX CV might steal from mine. You can download the .tex file and corresponding PDF, if you care to. Here’s an image of the final product’s first page:

I spent a good bit of time figuring out how my papers’ bibliographic info, exported from Mendeley in BibTeX format, could be quickly added to my CV. (One might argue that the hours spent figuring out how to add papers to your CV might be better spent writing papers. They’d be correct, but I stubbornly proceeded until success.) Here’s how I did it, with much help from the sites linked below.

I put all of my publications into a folder in Mendeley, which I called CV_Bergey_pubs. I made sure that all the info was correct and added the HTML markup for italicized text around species names (<i>…</i>), because I get anxious when I see, say, Papio kindae with normal font.

I then exported my Mendeley file to BibTeX format. This created a bunch of .bib files, one of which, CV_Bergey_pubs.bib corresponded to the folder of my publications. This file consisted of entries for all the papers, that looked something like this for my most recent paper:

abstract = {Descriptions of primate diets[...]},
author = {Pickett, Sarah B and Bergey, Christina M. and {Di Fiore}, Anthony},
doi = {10.1002/ajp.22014},
file = {:Network/Servers/ 
Desktop/Pickett, Bergey, Di Fiore\_2012\_A metagenomic study of primate insect 
diet diversity.pdf:pdf},
issn = {1098-2345},
journal = {American Journal of Primatology},
keywords = {dietary ecology,metagenomics,neotropical primates},
month = jul,
number = {7},
pages = {622--31},
pmid = {22553123},
title = {{A metagenomic study of primate insect diet diversity.}},
url = {},
volume = {74},
year = {2012}

I link to this BibTex file in my .tex file with the following line at the end of my CV:


These lines at the top tell LaTeX to load the natbib and bibentry libraries, and not to just start spitting out references, but rather wait until I say to do so:


This line at the top of the .tex file tells the compiler what format I’d like my bibliography in, APA-like:


After that I can quickly add the bibliographic info for my papers. The first line, @article{Pickett2012, shows the short name of the file, Pickett2012. You can edit this in Mendeley in the info window for each article. The default is AuthorYear. If I want to add the bibliographic entry for this article, I simply type:


So my full (relatively short) table of papers looks like this:

  2012 & \bibentry{Pickett2012} \\
  2011 & \bibentry{Bergey2011} \\
       & \bibentry{Jolly2011} \\
  2010 & \bibentry{Hodgson2010} \\
  2008 & \bibentry{Bergey2008} \\

I wish there were a bit more of those. Anyway, with a bit of help from an intro to LaTeX website, anyone should be able to take out my info and replace it with their own. Time will tell if I ever take the plunge and attempt to write my dissertation in LaTeX, but for now, the CV is working out well. Below are some links for those more interested in CVs in LaTeX and integration with Mendeley.

Links on Preparing a CV in LaTeX:

Links on Incorporating BibTeX: