Friday, November 21, 2008

Helpful UNIX commands

VI:

In vi, to copy the whole line and have it repeated (I use when doing mass mv or cp commands)

:%s/.*/& &/

REDIRECTION:

Dump to a file:

ls -1a > output.txt

Append to a file:

ls -1a >> output.txt

Redirect standard error:

ls -1a 2> error.txt

Run a script to redirect to a file AND show on the screen:

ls -1a | tee -a output.txt