I am looking for a way to create multiple files with one command and automate the process.
They should share a common name but different extensions. The extensions are always the same.
For example index.js, index.css, index.html
So instead of using
touch index.js, index.css, index.html
I would like to have an miracoules command which does something like this:
*miracle* index
and 3 files are created.
Best Answer
Something like
should work. Which of course can then be turned into a shell function with
The test ensures that the files only get created if a name is passed as an argument, the
touch --
ensures thatmiracle -foo
doesn't lead to an error.and used as
To have this defined automatically in
bash
add the function definition to~/.bash_profile
, forzsh
use~/.zprofile
.