After accepting the command entered by user,the shell generates a readily executable simple command line by parsing it evaluating variables(if present),performs command substitution,interprets metecharacters like * and ?(if present) and identifies the PATH.

Can anyone explain to me in simple terms the parsing part and identifying the Path part?

*text is taken from Unix and shell programming by M.G.Venkateshurthy

  • $\begingroup$ Please provide proper attribution for all content originally written by others. Copying text without credit is against our rules. Please refer to cs.stackexchange.com/help/referencing, and then edit your question to comply with our expectations. $\endgroup$
    – D.W.
    Feb 28, 2023 at 19:24
  • $\begingroup$ This is not a grammatical sentence in English. $\endgroup$ Aug 8, 2023 at 15:57

1 Answer 1


This is a question about Unix and shell programming. When you run a command like cp dir/* $destination the shell has to do several things to simplify this command before executing it:

  • Replace dir/* with a list of all the paths matching dir/* e.g. dir/file1 dir/file2 dir/file3
  • Replace $destination with the value of the variable destination e.g. otherdir

There are other steps not shown here, like command substitution - for example $(ls) is replaced by running the command ls and replacing it with whatever ls outputs.

Finally as a last step, generally separate from the others as it does not actually edit the command, the shell has to find the actual path of the cp command, usually at /bin/cp. It does this by looking at the variable PATH, which holds a list of directories, then looking in each directory to find an executable called cp.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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