• Unix

Filed under:

General notes on unix utilities, writing shell scripts, etc.

Misc & Examples

  • set -e at the top of your file means if any command in the script fails, the whole script will abort. By default, if you don't do this, bash will continue.

  • xargs can take multiple lines of input and turn them into arguments to another function.

  • You can make a sub shell in a command like so: <(cat /dev/null) (zsh, bash only)

  • tidy can be used to format output of HTML, XML. Ex: curl google.com | tidy.

  • view is a way to launch vim in a readonly mode.

    • example: curl google.com | tidy | view - where view - reads stdin.

  • You can run diff on arbitrary things:

# diff two arbitrary sites.
diff -u <(curl https://www.my-site.com/hi) <(curl https://www.localhost:3000/hi)


  • jobs show running jobs.

  • ctrl +z in a shell will turn an active process into a job

  • fg brings most recent job to the foreground.

  • fg %1 brings job 1 to the foreground

  • bg allows a job to run in the background.


A tar file, often called a tarball, is a collection of files wrapped up in one single file for easy storage.

tar -xzf tarfile

I commonly forget the order of symlinking something.

ln -s [target to symlink] [where to put symlink]
ln -s /mnt/external-drive ~/mydrive