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.
您可以使用bash扩展使其更简洁:
mkdir views && touch views/{layout,home,contact}.erb
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
mkdir views && pushd views && touch layout.erb home.erb about.erb contact.erb && popd
要么:
mkdir views && (cd views && touch layout.erb home.erb about.erb contact.erb)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.