Given a command entered at a normal bash prompt, how does bash read that line once you hit enter? does it do variable substitution then command substitution? or does it do bash expansion first? or what?

Given the command below, what does bash do start to finish?

for i in *.meow; do 
   cat <<WUTLOL
   FILE ${PWD}/$i
   scp $i $(grab_server.sh kitten_blast{1..3}): 

The Bash wiki explains this quite well. Paraphrasing:

  1. Read data to execute
  2. Process quotes
  3. Split the read data into commands
  4. Parse special operators
  5. Perform expansions
  6. Split the command into a command name and arguments
  7. Execute the command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.