Skip to content

Instantly share code, notes, and snippets.

@mediter
Last active December 4, 2018 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mediter/46a0887c34c310978473472930230f58 to your computer and use it in GitHub Desktop.
Save mediter/46a0887c34c310978473472930230f58 to your computer and use it in GitHub Desktop.
[bash for-loop with echo] #bash #for-loop #touch #echo

for-loop with echo

for model in "artists" "galleries" "paintings"
do
    mkdir -p $(echo views/api/v1/$model)
    for verb in "index" "show"
    do
        touch $(echo views/api/v1/$model/$verb.json.jbuilder)
    done
done

if the variable name could not be correctly recognized, use another $(echo ) to enclose it

mkdir -p controllers/api/v1; 
for m in "artists" "galleries" "paintings"
do
	touch $(echo controllers/api/v1/$(echo $m)_controller.rb)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment