Linux Online
[ Register ]

[ Applications ]
[ Documentation ]
[ Distributions ]
[ Download Info ]
[ General Info ]
[ Book Store ]
[ Courses ]
[ News ]
[ People ]
[ Hardware ]
[ Vendors ]
[ Projects ]
[ Events ]
[ User Groups ]
[ User Area ]

Linux Kernel Development

[ About Us ]
[ Home Page ]
[ Advertise ]

Getting Started with Linux - Lesson 10

'tee', '>', '2>'

In the lesson on the pipe command, I mentioned plumbing with Linux. I think I'm going to resist the temptation to make some sort of golf reference here in the lesson on the command 'tee'.

'tee' is used to write out what appears on your screen into a file. You will be using this with the after a pipe '|' .

You might do this:

ls -l | tee directory_listing

to get a file with the listing of a directory. If you've placed files in a directory to be backed up, you could use this command to create a listing of that directory. You could print out the file on a label and stick it to the disk, tape, zip cartridge or whatever you used to make the backups.

If you're using the 'tee' command for the backups I described before, you may want to put a date on the file. You can use this command:

date | tee -a directory_listing

The command 'date' will enter the date and time in the file at the end. Remember to use the -a option if you're going to write to that file a second time. If you don't you will erase everything on the file in favor of whatever the second command was.

The '>' command

The "greater than" symbol '>' will do the same as 'tee'. You don't need the pipe command (|) with this one.

ls -l > directory_listing
will give you the same result. If you want to add the date at the end, use the command:

date >> directory_listing

with two "greater than" symbols (>>)

The two symbols will add to the file without erasing its contents

The '2>' command

This command, the number two (2) with the "greater than" symbol >, is used for creating a file for an error message that you may get.

You will probably not be using it a lot because we all know how perfect Linux is and how few errors there are when you're using it. But every once and a while you may want to download some software from the Internet You install it and - whoops! - there's some error. You may not have something installed that the program needs to run. You could just do something like this:

[program X that doesn't work] 2> program_X_error

You create a file with the error message. You could show it to someone who might know what's missing or you could send it to the author of the program. He or she would also like to know about it and will probably help you fix it.

[Previous] [Next]




Comments: feedback (at) linux.org
Advertising: banners (at) linux.org
Copyright Linux Online Inc.
Compilation ©1994-2008 Linux Online, Inc.
All rights reserved.