Posts

Showing posts from September, 2019

Bash shell syntax goodies and gotchas

In my time bash scripting, I've come across a number of CLI goodies and gotchas, so I've decided to compile a post with a list of neat examples. These may be about individual packages or specific to the shell.


pdflatex -- the order of arguments matters :( For instance, I've written a bash script that's cron-scheduled to re-compile my resumé each morning. But, you must specify flags and options before the file name you're aiming to compile.pdflatex -var-value="$out" -output-directory="$misc" "$location" Otherwise, it fails. Watch out for rm'ing against filesystems as such -- read -r -p "Give me a file to delete: " var rm -r "$var/" If $var does not contain anything, then this could destroy your machine :P Instead, use rm -r "${var:?}/" For example, on my own machine -- root@ideapad:~# read -r -p "This: " that; echo "${that:?}/" This: -bash: that: parameter null or not set root@ideap…