Score:2

Cannot write long output to file

us flag

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.

hr flag
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`
Score:0
us flag

Here is what finally worked for me:

~$script output_1.txt  
~$<command>
~$exit
Score:0
zw flag

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
James Canova avatar
us flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.