Write a command that

  • feeds app data from input.dat
  • saves the output to output.dat
  • saves the error messages to log.txt

I am really new to Unix and was wondering if I am using the command line parameters correctly.

My command I was writing was:

$> app < input.dat > output.dat > 2> log.txt

From what I understand is the < reads files as standard input. > sets files as redirection from standard output, and 2> redirects error messages to a file.

Was wondering if my command is correct, and if not was wondering if someone could lend me a hand in this.

  • 1
    You just have an extra output redirection > in there. So app < input.dat > output.dat 2> log.txt Feb 26, 2021 at 1:20

1 Answer 1


Depending on how the app handles its input and assuming the input data is formatted correctly you could do something like this cat input.dat | app > output.dat 2> log.txt. The input is the part that hold most of the issues this really depends on how the app expects to receive its input ie. newline separated, tab separated ect..

You can also use the syntax you originally where trying.

app < input.dat > output.dat 2> log.txt

But personally I think the cat method is more versatile and common usage in Linux.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.