Link Search Menu Expand Document

Redirection

When running programs, it is useful to provide input from a file or to direct output to a file. The syntax [process] > [file] tells your shell to redirect the process’s standard output to a file. Similarly, the syntax [process] < [file] tells your shell to feed the contents of a file to the process’s standard input.

Modfiy your shell so that it supports redirecting stdout and stdin to/from files. You do not need to support redirection for shell built-in commands. You do not need to support stderr redirection or appending to files (e.g. [process] >> [file]). You can assume that there will always be spaces around special characters < and >. Be aware that < [file] or > [file] are not passed as arguments to the program (i.e. you will not find these characters in the argv argument of the main function in shell.c).