0

I am working with a command line package and to get its the output in a file I use:

my_command > outfile

but it also produces some information on the screen while running and writing the output in the outfile and I want the get the screen output in a second outfile. In the useful thread in here , there is no suggested way to separate these two outputs. Is there actually a way to separate these two outputs and write them in different files?

Masih
  • 920
  • 2
  • 19
  • 36
  • 1
    `my_command > outfile 2> errfile` I assume is what you want, however it's not quite clear to me if the output you're also trying to capture is stderr or part of the stdout output that needs to be filtered. Would you please clarify your question, perhaps naming the command and showing sample output? – bishop Jun 02 '19 at 00:51
  • 1
    Thanks @bishop. Seems that screen output was stderr and this fixed the issue. I didnt know that both '> 'and '2>' could be used at the same time. – Masih Jun 02 '19 at 01:07
  • Possible duplicate of [How to redirect stderr and stdout to different files in the same line in script?](https://stackoverflow.com/q/7901517/608639), [How can I redirect and append both stdout and stderr to a file with Bash?](https://stackoverflow.com/q/876239/608639), [Redirect stderr and stdout to separate files in Bash?](https://stackoverflow.com/q/22470010/608639), etc. – jww Jun 02 '19 at 01:45

1 Answers1

2

Sounds like the additional output comes from stderr, which you can capture with 2>:

mycommand > outfile 2> stderr
bishop
  • 37,830
  • 11
  • 104
  • 139