Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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
You can’t perform that action at this time.