Fish shell brace expansion

I mentioned that I use the fish shell, but I would like to share a common problem of mine – well, so far this is the only one I found.

I commonly use commands like this

find . -maxdepth 1 -type d -exec du -sh {} \;

This works great with bash, but in fish you got the following error message

 du: fts_open: No such file or directory 

This happens, because fish acts more aggressive on brace expansion than bash. It doesn’t treats it as a part of command, but tries to expand it – but cannot succeed, because there is nothing.
Simply put that inside apostrophes and the shell will skip the brace expansion.

find . -maxdepth 1 -type d -exec du -sh '{}' \;

Not a big thing, but handy.

Share This: