Intel's Ronler Acres Plant

Silicon Forest
If the type is too small, Ctrl+ is your friend

Wednesday, September 10, 2008

Command Line Redirection

When you are using a text box to enter commands in a computer, be it Linux or a DOS box on Windows, the command may send some output to the screen. If it is generating a lot of output that you want to be able to study at your leisure, it would be nice to collect all this information in a file.

The standard trick for doing this is to redirect the output to a file using the greater than sign, like this:

dir > dir.lst

The dir command will list all the files in your current directory. This command, with the redirect symbol, it will put a list of all those files in a file called "dir.lst".

While I was fooling with Linux yesterday, this trick did not work. I was a little shocked and a little disappointed, but I was able to get by and get my work done anyway. Afterwords, I was doing a little poking around, examining the debris left from my mad thrashing, and I discovered something slightly unsettling. A great number of commands are defined like environment variables. Take a look at what set produces. Less than half of what comes back is standard environment variable definitions. The rest of it is page upon page of procedures written in some arcane script language. No wonder redirection doesn't work.

No comments: