Search code examples
cbashcommand-line-argumentsstdoutstdin

What does the following bash program call do?


I am going through my revision material and can't understand the following:

I have a compiled C myCProgram program which prints out its input in the form of text. So if it were called in bash by ./myCProgram input.txt and input.txt contained "this is a test" the program would output on stdout "this is a test". I have a range of potential bash program calls to test and I pass all but one, it is of the following

./myCProgram file.txt < input.txt

It is is decribed as: Your program takes a file as a single command line argument and then expect input on stdin.

Can anyone explain to me what is going on here and suggest how I should handle it within my code?


Solution

  • This redirects the content of input.txt to your program via stdin. This does the same as:

    ./myCProgram file.txt
    

    and then typing in the contents of input.txt