General notes on unix utilities, writing shell scripts, etc.
Misc & Examples
set -eat 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.
xargscan 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)
tidycan be used to format output of HTML, XML. Ex:
curl google.com | tidy.
viewis a way to launch vim in a readonly mode.
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)
jobsshow running jobs.
ctrl +zin a shell will turn an active process into a job
fgbrings most recent job to the foreground.
fg %1brings job 1 to the foreground
bgallows 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