Tag Archives: redirect

Redirecting Output from Terminal to a file

Today, I was trying to get a scheduler simulator up and running. The source code had a Makefile which was doing quite some job. I tried to do a make only to end up with a lotta errors. The list of errors was so long that the terminal didn’t show up the entire error by scrolling up. I tried to redirect it to a text file using

$ make | tee filename.txt

But, instead of getting the errors, what I got was the entire make command after getting proccessed. I was interested in the errors rather than what the make command was.
I used this useful feature called script. All you gotta do is run the script command before you start.

$ script

You’ll get the prompt

$ Script started, file is typescript

This is the system’s way of telling that the system is recording everything going on the terminal
Once you’re done recording, just type the exit command

$ exit

And tada… its done, the terminal tells you

$ Script done, file is typescript

Everything goes into the file ‘typescripit’ which is created into the current directory.
For details checkout the manpages for script

$ man script

Advertisements