Sunday, March 19, 2006
con
Try to make a file (or directory) named con - you can't do it (if you're using some version of Microsoft Windows). This is a relic of MS-DOS still present in Windows XP. "con" is short for console and directs input/output to the console rather than a to a file.
enter copy con at the command prompt. (If you don't know how to get to the command prompt, hit start->run and enter cmd ) You'll get a cursor on a blank line. Now start typing. Enter whatever you'd like. Notice the strange results. This is very similar to the unix "cat" command. hit CTRL+C to get back to the prompt.
Now enter copy con newfile.txt at the command prompt. Whatever you type will be output to newfile.txt instead of echo'd back to the screen. Type CTRL+Z then hit ENTER to stop input. Now open newfile.txt to see what you've created.
If you are very familiar with the linux command line, then you can stop reading now as the following will all seem very basic.
This is all very basic stuff for linux command line use - but it's much more intuitive in linux. In win/dos if you hit cntrl+c to end input, the OS will throw away everything you've written and say that 0 files were copied - in linux ctrl+c will end input, but the file will be created. also in linux the command would be cat > newfile.txt - cat is much more functional than copy - especially when paired with other command line tools. "cat" is short for "concatenate" as it was originally intended to concatenate two or more files cat file1 file2 > newfile will do just that - newfile will contain the contents of file2 tacked to the end of the contents of file1. It is also commonly used to list short text files cat anyfile will display the contents of "anyfile" on the screen. cat file1 file2 will display the contents of both files on the screen (you could specify as many files as you'd like - you aren't limited to 2).
Of course cat is not the best tool for displaying files. more will stop at the end of each screenfull to allow you to read a screen at a time - cat will just keep going as if you could read it as fast as it can output it. of course there is an even better tool than more - it is called less. less not only waits for you to read each screenfull, it allows you to scroll backwards and read something from a previous screen.
If any of this sounds new and exciting to you, then you need to get a copy of linux and start playing with it - maybe on some old piece-of-junk computer you've got sitting in a closet somewhere - linux will fit and run nicely on it if you find the right distribution. Don't even install a GUI the first time you install it. Just install the very basic packages and play around with the command prompt - it'll help of you have another computer nearby connected to the internet so that you can go to the linux documentation project website and read up. I suggest the Linux User's Guide (LUG) - which is quite outdated, but still very relevant because the command line and unix filesystem basics remain rather constant. It's not that complicated or hard to learn. Think of how hard it must seem to a kindegardener learning to read - he may want to give up and just look at the pictures, but reading really isn't that hard and it's definitely worth the initial effort.
enter copy con at the command prompt. (If you don't know how to get to the command prompt, hit start->run and enter cmd ) You'll get a cursor on a blank line. Now start typing. Enter whatever you'd like. Notice the strange results. This is very similar to the unix "cat" command. hit CTRL+C to get back to the prompt.
Now enter copy con newfile.txt at the command prompt. Whatever you type will be output to newfile.txt instead of echo'd back to the screen. Type CTRL+Z then hit ENTER to stop input. Now open newfile.txt to see what you've created.
If you are very familiar with the linux command line, then you can stop reading now as the following will all seem very basic.
This is all very basic stuff for linux command line use - but it's much more intuitive in linux. In win/dos if you hit cntrl+c to end input, the OS will throw away everything you've written and say that 0 files were copied - in linux ctrl+c will end input, but the file will be created. also in linux the command would be cat > newfile.txt - cat is much more functional than copy - especially when paired with other command line tools. "cat" is short for "concatenate" as it was originally intended to concatenate two or more files cat file1 file2 > newfile will do just that - newfile will contain the contents of file2 tacked to the end of the contents of file1. It is also commonly used to list short text files cat anyfile will display the contents of "anyfile" on the screen. cat file1 file2 will display the contents of both files on the screen (you could specify as many files as you'd like - you aren't limited to 2).
Of course cat is not the best tool for displaying files. more will stop at the end of each screenfull to allow you to read a screen at a time - cat will just keep going as if you could read it as fast as it can output it. of course there is an even better tool than more - it is called less. less not only waits for you to read each screenfull, it allows you to scroll backwards and read something from a previous screen.
If any of this sounds new and exciting to you, then you need to get a copy of linux and start playing with it - maybe on some old piece-of-junk computer you've got sitting in a closet somewhere - linux will fit and run nicely on it if you find the right distribution. Don't even install a GUI the first time you install it. Just install the very basic packages and play around with the command prompt - it'll help of you have another computer nearby connected to the internet so that you can go to the linux documentation project website and read up. I suggest the Linux User's Guide (LUG) - which is quite outdated, but still very relevant because the command line and unix filesystem basics remain rather constant. It's not that complicated or hard to learn. Think of how hard it must seem to a kindegardener learning to read - he may want to give up and just look at the pictures, but reading really isn't that hard and it's definitely worth the initial effort.