From dd6ac81fe8176242dc13253327e6d6acccef5ebd Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 18 Jun 2018 09:00:59 +1000 Subject: [PATCH] Added brace expansion --- README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/README.md b/README.md index 262e1f2..aaacb38 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,9 @@ scripts and not full blown utilities. * [Arithmetic](#arithmetic) * [Simpler syntax to set variables.](#simpler-syntax-to-set-variables) * [Ternary tests.](#ternary-tests) +* [Brace Expansion](#brace-expansion) + * [Ranges](#ranges) + * [String Lists](#string-lists) * [Obsolete Syntax](#obsolete-syntax) * [Shebang.](#shebang) * [Command Substitution.](#command-substitution) @@ -993,6 +996,40 @@ Downloads ((var=var2>var?var2:var)) ``` +# Brace Expansion + +## Ranges + +```shell +# Syntax: {..} + +# Print numbers 1-100. +echo {1..100} + +# Print zero-padded numbers. +echo {01..100} + +# Print range of floats. +echo 1.{1..9} + +# Print chars a-z. +echo {a..z} +echo {A..Z} + +# Nesting. +echo {A..Z}{0..9} +``` + +## String Lists + +```shell +echo {apples,oranges,pears,grapes} + +# Example Usage: +# Remove dirs Movies, Music and ISOS from ~/Downloads/. +rm -rf ~/Downloads/{Movies,Music,ISOS} +``` + # Obsolete Syntax ## Shebang.