Home > Enterprise >  Why doesn't the Linux redirection operator capture the output of my command?
Why doesn't the Linux redirection operator capture the output of my command?

Time:09-23

Context: I have a program (go-sigma-rule-engine by Markus Kont) on my EC2 instance that runs against a logfile and produces some output to screen.

The command used to run this program is ./gsre/go-sigma-rule-engine run --rules-dir ./gsre/rules/ --sigma-input ./logs/exampleLog.json

The program produces output of the form:

INFO[2021-09-22T21:51:06Z] MATCH at offset 0 : [{[]  Example Activity Found}]   
INFO[2021-09-22T21:51:06Z] All workers exited, waiting on loggers to finish   
INFO[2021-09-22T21:51:06Z] Stats logger done   
INFO[2021-09-22T21:51:06Z] Done

Goal: I would like to capture this output and store it in a file.

Attempted Solution: I used the redirection operator to capture the output like so:
./gsre/go-sigma-rule-engine run --rules-dir ./gsre/rules/ --sigma-input ./logs/exampleLog.json > output.txt

Problem: The output.txt file is empty and didn't capture the output of the command invoking the rule engine.

CodePudding user response:

Maybe the output you want to capture goes to standard error rather than standard output. Try using 2> instead of > to redirect stderr.

  • Related