Making a basic shell and I need to handle file redirection. Specifically I am stumped on how I can feed data into a program like sort
for example from a file.
Something on the command line would look like this:
$ sort < test.txt
How do I accomplish this kind of functionality in my own mini shell made in C?
I thought that maybe sort
read from stdin
but I guess I can't really write the contents of a file to stdin
due to the read only aspect so I'm wondering how I actually get this data into something like sort
for example? I am currently using forks and then using execvp()
to execute programs.