2

I'm a beginner. I'm using Ubuntu 18.04

I am trying to send the output from a command that installs dependencies for a subsequent install command.

I have tried:

$ my_command > output.txt
$ my_command >> output.txt
$ my_command | tee output.txt

I always just get the last, maybe, one hundred lines of output. I am loosing some lines of output because I watch them scroll by on the terminal. I might be loosing a few hundred lines of output. I have searched the Internet and can't find much except to install xfce4-terminal which I do not want to try because I am worried about losing my existing desktop.

I am assuming that xfce4-terminal must be interacting with command lines, but what are they?

Thank you for any assistance in advance.

Soren A
  • 6,799
  • 3
    Are you sure that my_command is writing exclusively to the standard output stream, or is it possible that some lines are being written to the standard error stream? If you want to capture the latter as well, use > output.txt 2>&1 or (in bash) &> output.txt – steeldriver Dec 01 '21 at 23:17

2 Answers2

0

You are missing append flag for tee, see man tee locally or online:

tee [OPTION]... [FILE]...
Copy standard input to each FILE, and also to standard output.

-a, --append append to the given FILEs, do not overwrite

Correct command sequence would be:

my_command > output.txt
my_command >> output.txt
my_command | tee -a output.txt
N0rbert
  • 99,918
  • Thank you for the suggestions. Unfortunately the command that was generating hundreds of lines of output (a pip3 command to install multiple dependencies) is for some unknown reason not now doing so. So, I can't try the suggestions out. – James Canova Dec 03 '21 at 12:38
0

Here is what finally worked for me:

~$script output_1.txt  
~$<command>
~$exit
matigo
  • 22,138
  • 7
  • 45
  • 75