1

new to Linux and C so probably a simple task..but
As per the title,

How, via the command line, do you redirect 2 distinct files as input, so that when the program is done with the first, it will move on to the second?

./a.out < in1.txt   .......
avcJav
  • 317
  • 3
  • 10
  • 1
    How does this relate to C? Are you asking about shell redirection? – teppic Oct 15 '15 at 19:48
  • 1
    if you want to send file1, file2... as input for stdin to a program you just have to use `cat` → `cat file1 file2 file3 | ./my_program`. And it has nothing related to C. – hexasoft Oct 15 '15 at 19:52

1 Answers1

4

Probably what you are looking for is

cat in1.txt in2.txt ... | ./a.out

which will use cat to concatenate the named files to stdout, and the | (pipe) operator to take the stdout from the left and feed it into the stdin on the right.

./a.out > in1.txt

redirects stdout, not stdin. If you want to redirect stdin, use

./a.out < in1.txt

But you can only specify one file.

With bash, you can also redirect from the output of a command:

./a.out < <(cat in1.txt in2.txt)
rici
  • 234,347
  • 28
  • 237
  • 341
  • that's it. thanks a lot rici. novice question, i know. i appreciate your time and patience. – avcJav Oct 15 '15 at 19:59