parent and child processes in command substitution

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kneielj
    New Member
    • Jul 2007
    • 6

    parent and child processes in command substitution

    How does the shell interpret command substitution ?
    if its a normal command, the shell would spawn a child process and the parent would wait for the child to execute and would then collect its exit status.

    if it is a backgroundproce ss, then the parent woul not wait on the child.

    in similar context, how would command substitution be executed by the shell ?
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Originally posted by kneielj
    How does the shell interpret command substitution ?
    if its a normal command, the shell would spawn a child process and the parent would wait for the child to execute and would then collect its exit status.

    if it is a backgroundproce ss, then the parent woul not wait on the child.

    in similar context, how would command substitution be executed by the shell ?
    I am not quite sure what you mean by "command substitution." Could you please elaborate?

    Comment

    • kneielj
      New Member
      • Jul 2007
      • 6

      #3
      Originally posted by Motoma
      I am not quite sure what you mean by "command substitution." Could you please elaborate?
      by command substitution, i meant commands within the abck quote ` command`

      eg. cut -d " " -f 1 `date`

      Comment

      • Motoma
        Recognized Expert Specialist
        • Jan 2007
        • 3236

        #4
        The stdout from the command is placed inline:

        ls `echo $HOME`
        The echo command will print the path of your home directory, and ls will take that result and give a directory listing (this is the same as ls $HOME)

        grep -i motoma `find . -name "*.txt" -f`
        Will return all of the regular files in the current directory that end in .txt and contain my name.

        Comment

        Working...