How do I use dup2 to perform the following command?
ls -al | grep alpha | more
You would use pipe(2,3p) as well. Create the pipe, fork, duplicate the appropriate end of the pipe onto FD 0 or FD 1 of the child, then exec.
pipe(2,3p)