Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
   WUTLOL
   scp $i $(grab_server.sh kitten_blast{1..3}): 
done
share|improve this question
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.