-2

Is it possible in linux to start a program ./program and everything it outputs gets written to a output.txt file?

1

1 Answer 1

3

How about ./program > /tmp/mylogfile.txt 2>&1

sending everything to the /tmp/mylogfile.txt file.

The > is a redirection of standard out (stdout) and the 2>&1 redirects standard error (stream file descriptor 2) to standard out (stream file descriptor 1)

Sign up to request clarification or add additional context in comments.

3 Comments

Works like a charm but it stopped printing it on the actual console, can I make it console + file?
To answer your first point, investigate 'tee'. To answer your second point, not so easy, but I'm sure there's a solution out there using the 'date' utility and perhaps a script to pipe (not redirect) into
Wdym investigate 'tee'?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.