Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • See here. Try using exec. Commented Sep 23, 2014 at 16:10
  • That doesn't work the way you say it does. Using 'exec' in a command substitution just forks a shell that immediately exits, incurring the full overhead and other issues of spawning a subshell; you can verify this by '/usr/bin/echo'ing $BASH_SUBSHELL within such an invocation. Commented Sep 23, 2014 at 16:26
  • See Vinc17's answer below. An implicit exec vs something like an explicit exec: exec 2>/dev/null Commented Sep 23, 2014 at 16:32
  • foo=$(grep ... | awk) spawns one subshell, for the command substitution. Commented Sep 26, 2014 at 2:09
  • 1
    You can spare one process: foo=$(awk '/someword/ {print $3}' /path/to/somefile)... Commented Oct 30, 2014 at 0:10