Here's an example of how to use brace expansion in a script using /bin/dash:
#!/bin/sh
# create directories using brace expansion
mkdir {test1,test2,test3}/{dir1,dir2}
# create files using brace expansion
touch {test1,test2,test3}/file{1..5}.txt
In this script, we're creating three directories with subdirectories within them using brace expansion (test1/dir1
, test1/dir2
, test2/dir1
, etc.). We're also creating files in each of these directories using brace expansion (file1.txt
, file2.txt
, etc.).
Note that in dash (which is a minimal shell), brace expansion is not enabled by default. To enable it, you can set the set -B
option at the beginning of your script.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-17 09:05:54 +0000
Seen: 14 times
Last updated: May 17 '23
How can data extraction from BigQuery and loading it into SQL Server be done in an optimal manner?
How can one ensure that sub-classes have uniform method parameters in TypeScript?
How can the calculation of matrix determinant be performed using CUDA?
How can code repetition be prevented when using (box)plot functions?
When I attempt to generate a database, why does the azure-cosmos-emulator become unresponsive?
What steps can I take to prevent my webpage from slowing down when all parts of a div are displayed?