Thanks! This bash string escape trick will be really useful for me(1). It is one of the biggest pain points in using cli especially with nested commands like su -c where the actual command is supposed to go inside quotes and becomes hell to quote if it too has nested quotes inside it.
Oh how i wish that bash and every other language would support the Perl's brilliant `q()` and `qq()` for quoting strings. That simple fn really made life very easy and code cleaner.
Yes I learned the same too yesterday from Hacker news. What a coincidence! There was also a bashquote function which you can put in your .bashrc file but this approach really beats everything!
Oh how i wish that bash and every other language would support the Perl's brilliant `q()` and `qq()` for quoting strings. That simple fn really made life very easy and code cleaner.
(1) https://til.simonwillison.net/bash/escaping-a-string