To quote, or not to quote, that is the question

You can feel alone when learning shell

Do I need to quote my password?

$ rm crazy\ file\ name\ with\ spaces
$ rm "crazy file name with spaces"
$ rm 'crazy file name with spaces'
$ rm crazy\ file" "nam'e 'with" spac"es

Can I haz my vars?

$ cat "I'm learning to quote with strange filenames.txt"
$ cat 'I'\''m learning to quote with strange filenames.txt'
$ cat 'I'"'"'m learning to quote with strange filenames.txt'
$ var=myvalue
$ echo "with double quotes \$var is interpreted as $var"
with double quotes $var is interpreted as myvalue
$ echo 'with single quotes $var is not interpreted'
with single quotes $var is not interpreted
$ echo hello
hello
$ echo "last param was $!"
last param was hello

Minus + minus = plus?

$ rm -- -f
$ rm -- "-f /"

Going further?

#!/bin/bash
wrappedcommand "$@"

--

--

We are Open Source Engineers, Hacking Awesome Stuff

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store