3 ms·
This almost always works, but it won't if the shell expands your bracketed letter. See for example: $ echo [b]anana [b]anana $ touch banana $ e
by stonewareslord 5y ago
This almost always works, but it won't if the shell expands your bracketed letter. See for example:
$ echo [b]anana
[b]anana
$ touch banana
$ echo [b]anana
banana
You can escape the bracket and it will work:
$ echo \[b]anana
[b]anana
- srcreigh 5y agoI tested with zsh, apparently even if there's no matches it still complains. Escaping works under zsh. My preferred method is single quotes: echo '[b]anana'
- michaelcampbell 5y agoI remember reading about this trick 20-some years ago, but it's still as good now as it was then.
- stonewareslord 5y agoWhich zsh version? On 5.7.1, echo \[b]anana works in both cases