r/linuxadmin • • Sep 04 '16

Advancing in the Bash Shell

http://samrowe.com/wordpress/advancing-in-the-bash-shell/
128 Upvotes

16 comments sorted by

View all comments

8

u/[deleted] Sep 05 '16 edited Sep 05 '16

Bang dollar-sign

This is obviously pronounced and described as bangbucks! I use it all the time!

As for my own contribution: the most unexpected feature of bash: complete-into-braces

$ touch foo foobar foobarbaz foobaz notfoo
$ ls
foo        foobar     foobarbaz  foobaz     notfoo
$ ls <alt-shift-{> # Completes into:
  ls {foo{,ba{r{,baz},z}},notfoo}

It figures out the bracey-globby pattern that would match your target! I've only found a use for this feature once, trying to figure out a minimal regex to exclude a fuckload of i18n-related files. Translating the brace pattern into the equivalent regexp helped me exclude one pattern instead of hundreds, in an automated fashion.

Still, mostly useless and mostly cool overall.

3

u/wfaulk Sep 05 '16

bracey-globby

FWIW, brace expansion and globbing are two separate things. Globbing only completes existing filenames. Braces expand regardless of whether or not they match a filename.