Tuesday, April 28, 2009

Using the command line to get the external IP

Lifehacker hints on how to get your external IP-address from the command line. You can use either curl or wget, using either of the following commands:

curl -s myip.dk |grep '"Box"' | egrep -o '[0-9.]+'

or

wget -O - -q myip.dk |grep '"Box"' | egrep -o '[0-9.]+'

OS X do not come with wget preinstalled (it can be installed through e.g. Fink or MacPort), the curl version might be the most useful for OS X users.

Wednesday, April 8, 2009

Use 'ls' to only show directories

Lifehaker has a great tip on how to use 'ls' to only show the subdirectories at the command prompt. When you know about it, it is kind of obvious (if you know some simple regexp), but a it is still very handy. 

So, what you do is to type

    ls -l | grep ^d

at the command prompt. This will only list your subdirectories. 

Saturday, April 4, 2009

Line numbers in LaTeX

As I am doing a bit of writing, I suddenly had the need to have line numbers in my LaTeX document. There is a really nice package called lineno that takes care of this very nicely. All you have to do is include the package, and put the command \linenumbers somewhere in your document. I placed the following two lines in my preamble:

  \usepackage{lineno}
  \linenumbers

You will find the documentation for lineno at ctan.