Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is a rather long list so i'll just mention my latest favorite which I recently learned on HN and it has made my life very easy with bash

Whenever you need to use a single-quote on command line add a $ sign before it. It makes escaping everything super easy

    su user -c $'cd \'$dir\' && ...'
Before this it used to confuse the hell out of me.

More details are here: https://stackoverflow.com/a/16605140/1031454



I know that may be convenient, but you'll want to exercise caution because $'' turns on inner escaping that wouldn't otherwise happen inside single-quoted strings

    $ echo 'hello \"world'
    hello \"world
    $ echo $'hello \"world'
    hello "world




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: