Steps That a Shell Follows While Processing a Command

Explain the steps that a shell follows while processing a command.

After the command line is terminated by the key, the shell goes ahead with processing the command line in one or more passes. The sequence is well defined and assumes the following order: 

  • Parsing: The shell first breaks up the command line into words, using spaces and the delimiters, unless quoted. All consecutive occurrences of a space or tab are replaced here with a single space.

  •  
  • Variable evaluation: All words proceeded by a $ are evaluated as variables, unless quoted or escaped.

  •  
  • Command substitution: Any command surrounded by backquotes is executed by the shell which then replaces the standard output of the command into the command line.

  •  
  • Wildcard interpretation: The shell finally scans the command line for wildcards (the characters *, ?, [, ]). Any word containing a wildcard is replaced by a sorted list of filenames that match the pattern. The list of these filenames then forms the arguments to the command.

  •  
  • PATH evaluation: It finally looks for the PATH variable to determine the sequence of directories it has to search in order to hunt for the command.
Relevance Read:

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.