pure-bash-bible/manuscript/chapter9.txt

43 lines
607 B
Plaintext
Raw Permalink Normal View History

2018-06-20 08:00:33 +02:00
# BRACE EXPANSION
2018-06-20 05:03:53 +02:00
## Ranges
```shell
2018-06-20 05:03:53 +02:00
# Syntax: {<START>..<END>}
2018-06-20 05:03:53 +02:00
# Print numbers 1-100.
echo {1..100}
2018-06-20 05:03:53 +02:00
# Print range of floats.
echo 1.{1..9}
# Print chars a-z.
echo {a..z}
echo {A..Z}
# Nesting.
echo {A..Z}{0..9}
# Print zero-padded numbers.
# CAVEAT: bash 4+
echo {01..100}
# Change increment amount.
# Syntax: {<START>..<END>..<INCREMENT>}
# CAVEAT: bash 4+
echo {1..10..2} # Increment by 2.
```
2018-06-20 05:03:53 +02:00
## String Lists
```shell
2018-06-20 05:03:53 +02:00
echo {apples,oranges,pears,grapes}
# Example Usage:
# Remove dirs Movies, Music and ISOS from ~/Downloads/.
rm -rf ~/Downloads/{Movies,Music,ISOS}
```
<!-- CHAPTER END -->