recovering records from terminal/console buffer

Juan Manuel Palacios yellowdog-general@lists.terrasoftsolutions.com
Sun Jul 21 09:49:01 2002


	O.K., let me see if I got it straight. If what you want is to read 
what just went out of your terminal window you can "scroll" up with the 
combination cmd-up(arrow) and back down with cmd-down(arrow). Now if 
what you want is to pick up what comes to your screen, technically 
called "standard out", before it gets there and redirect it somewhere 
else like a file, you have to use a "redirector". A simple example, you 
do not want to see the listings of a directory but rather store them in 
a file:

ls > /path/to/file/where/you/want/the/information/

	More specifically:

[PowerBook:~] juan% ls > example   <--- creates the example file in the 
home directory with the listings of the home directory
[PowerBook:~] juan% ls > /var/root/example  <--- creates the same file 
but in root's home (if permissions allow)

	Now, if you wish to add something else to an already existing file 
you cannot use what I just wrote here because that will create a new 
file with the new output. You have to "append":

[PowerBook:~] juan% ls -laF --color  >> example  <--- appends the output 
of the new command to the already existing file

	That is for standard out. You can basically redirect it anywhere 
you want. And what about the errors a command may produce? That is 
called standard error. The shell keeps track of them by labeling each 
one with a static number, so standard out is one (1) and standard error 
is two (2). The previous examples are equivalent to:

[PowerBook:~] juan% ls 1> example  <--- redirection of the first output 
to the file

	Now, you may want to redirect the output and ditch the errors, so 
standard error also needs to be redirected:

[PowerBook:~] juan% mv /etc/*~ backup/ 2>/dev/null  <--- moves the files 
and dumps the errors to null so that they don't appear in the screen

	You could also redirect both at the same time:

[PowerBook:~] juan% ls -laF --color 1> example 2>/dev/null

	And you could combine them. Say that apart from the listings of the 
directory you also want to store the errors:

[PowerBook:~] juan%ls -laF --color 1> example 2>&1

	This tells the shell to put the standard output to the file and to 
redirect the standard error to standard output. And with those basics 
you can play and play for ever. Read the man page for the shell you're 
using (man bash, man tcsh, etc.) and you'll learn a huge deal of tricks 
you can do with the commands, their inputs and outputs.

	Hope that helps, hope that's what you were asking for. Regards,...


		Juan.

On Sunday, July 21, 2002, at 07:08  AM, Derick Centeno wrote:

> Greetings:
> Does anyone recall how to collect data which has scrolled off the
> console/terminal window?  I know that everything is sent to a
> terminal/console buffer which is also itself a file.  I want to "read"
> and copy data from that file and place it into one which can be used, 
> read
> and modified within vim or vi.
>
> Any answers/ideas??
> Thanks for your help. Derick.
> _______________________________________________
> yellowdog-general mailing list
> yellowdog-general@lists.terrasoftsolutions.com
> http://lists.terrasoftsolutions.com/mailman/listinfo/yellowdog-general