Reputation: 1898
I'm using command below in my mac machine:
mkdir views && touch views/layout.erb views/home.erb views/about.erb views/contact.erb
It's working as expected. But i'm looking for something, so that i don't have to use directory name(views) to create/touch each file.
Upvotes: 0
Views: 258
Reputation: 96131
You can do something like:
mkdir views && touch views/{layout,home,about,contact}.erb
Or you can change the directory in a sub-shell, so your current shell's working directory is unchanged:
mkdir views && (cd views && touch layout.erb home.erb about.erb contact.erb)
Another option is to use a loop:
mkdir views && for f in layout home about contact ; do touch views/${f}.erb ; done
Upvotes: 2
Reputation: 181745
mkdir views && pushd views && touch layout.erb home.erb about.erb contact.erb && popd
Or:
mkdir views && (cd views && touch layout.erb home.erb about.erb contact.erb)
Upvotes: 1
Reputation: 36511
You can use bash expansion to make this more concise:
mkdir views && touch views/{layout,home,contact}.erb
Upvotes: 4