Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}): 
share|improve this question
up vote 2 down vote accepted

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
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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