Lore Michael Lones

A Collection of Random Unix Commands

This collection of apparently random commands and expressions is to remind me how to do things in unix. Hopefully other people might find it useful too.

Apply a command to multiple files:
find <path> -name <file-pattern> -type f -exec <command> '{}' \;

Concatenate multiple files:
cat `find -name <file-pattern>` > <output-file>

Strip end of line characters:
tr -d '\r' < <input-file> > <output-file>

Syntax highlight code in html:
vim -f +"syntax on | let html_use_css = 1 | source \$VIMRUNTIME/syntax/2html.vim | write | qall" <input-file>

Count columns:
awk '{ if (NR==1) {print NF} }' <input-file>

Suspend/resume a process:
kill -SIGSTOP <pid>
kill -SIGCONT <pid>

Compress/decompress a directory:
tar -zcf dir.tar.gz dir tar -zxf dir.tar.gz

Convert to upper-case:
tr [:lower:] [:upper:] < <input-file> > <output-file>

Print a latex table to pdf:
\pagestyle{empty} in preamble of latex file containing table
latex table.tex
dvips -E -o table.ps table.div
pstopdf table.ps
pdftops -eps table.pdf

These web pages use Google Analytics to track visits. See Privacy Statement.
© Michael Lones 2005-2016. Page last updated 30th October, 2013.