Score:-1

How to change the input and output path of the time command

ht flag

I want change i/o of the time command, lake the following commands, but they are wrong and do not work. How to do this correctly?

time echo hello > log

bash -c 'time echo hello' > log

echo $(time echo hello) > log
waltinator avatar
it flag
Read `man test`. `test` does not read STDIN, does not write STDOUT or STDERR, it just sets `$?` (`$STATUS`). What do you want to change?
hr flag
@waltinator if the OP is using bash, then `help test` is likely more pertinent than `man test`. AFAIK both the bash shell builtin `test` and external `/usr/bin/test` *do* write to the standard error stream (and will do so in this case ex. `test: echo: unary operator expected` or `/usr/bin/test: missing argument after ‘hello’`).
hr flag
The bash `>` operator only redirects the standard output stream - if you want to redirect standard error to a file, see this similar question [Command output is not redirected to file](https://askubuntu.com/questions/1269712/command-output-is-not-redirected-to-file)
UnitedKingdom avatar
ht flag
I'm so sorry. test no. TIME
Score:-1
bs flag
knu

time (sleep 1 ; echo hello >log1) 2>log2

UnitedKingdom avatar
ht flag
time (command) 2> outfile
I sit in a Tesla and translated this thread with Ai:

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.