Tag Archives: Linux

Using find and xargs

In regular linux or unix you can recursively find the files in a subdirectory and apply some utility with arguments on them using xargs as,

find <dir> -type f | xargs <utilitiy> <args>

If the filenames in <dir> have spaces, quotation marks, or other characters in their filenames that make xargs barf, then you can use the following.

find <dir> -type f print0 | xargs -0 <utility> <args>

That should totally work–unless you’re on SunOS, then you have to do,

find <dir> -type f -exec <utility> <args> {} +

It looks crazy, I know, but that’s the honest truth.

Creating a Flowchart with TikZ and LaTeX

In this post I’ll discuss how to make simple flowcharts in LaTeX using TikZ. Probably the best collection of TikZ examples can be found at TeXample.net, but there are other helpful examples like these two PDFs, here and here. In case you’re wondering, TikZ is a recursive acronym “TikZ ist kein Zeichenprogramm,” a reminder (in German) that it is not an interactive drawing program.

Continue reading

Local Variables and Return Values in BASH

In this post, I’ll discuss some lessons learned from BASH programming, in particular, how to pass return values from BASH’s “functions”. BASH does not provide support scoped variables by default, so variables declared in a function are available everywhere once the function has been called. BASH will let you declare local variables within a function through the local keyword. Returning values is then a matter of echoing them out.

Continue reading

An Introduction to Vim

This post will represent some running notes regarding the use of the Vim editor. Why should you use something as arcane as Vim you ask? Well, sometimes you find yourself on a server or something that doesn’t have any other editors, so you should be know some Vim basics. Plus, it’s fun.

Vim is built on vi, an even more bare-bones editor. At the outset you should know that Vim has two modes, normal or command mode, and edit or insert mode. You add words and stuff in edit mode, and you perform operations like searching, saving, and moving around in normal, or command mode. (I prefer the edit/command terminology.) You can always get into the command mode by hitting ESC.

Continue reading

Creating a Presentation with R

In this post I’ll look at creating a presentation using the R ecosystem. I’ve used beamer before, and I love it, but I haven’t used the knitr R package yet. Incidentally, the creator of knitr, Yihui Xie, does not like beamer. This is fine, I have been wrong about technology before–I recall thinking in college that facebook was for losers and that it would never catch on. Anyway, Yihui’s work is really impressive and I strongly suggest checking it out.

Continue reading