![]() |
downloads | documentation | HowTo | reporting bugs | links | Recent Changes |
What is a Wiki?See WikiWikiWeb If you don't know how to use a wiki see the WikiHowto ErfurtWiki is maintained by a loosely knit group of developers. Quick LinksRelated sitesContactPlease submit website bugs in the BugReports Contribute!Please file any wishes on UserSuggestions. Hosted By |
All unix programs have three IO streams by default 0 - input, formally standard input. it is referred to as SDTIN 1 - output, formally standard output. it is referred to as SDTOUT 2 - error, formally standard error. it is referred to as SDTERR by default all input comes from the keyboard and all output (STDOUT and STRERR) goes to the screen. Example: cat /tmp/file if the file exists, the cat command will sent the contents of the file to standard out, the screen. if the the file does not exist, cat will send an error message to standard error, still the screen Often is is useful to redirect an output stream into a file. the output redirection operator is >. 1> redirects SDTOUT and 2> redirects STDERR STDOUT example cat /tmp/file 1> newfile if the file exists, the cat command will sent the contents of the file to standard out, newfile. if the the file does not exist, cat will send an error message to standard error, still the screen since we did not redirect STDERR with 2> STDERR example cat /tmp/file 2> newfile if the file exists, the cat command will sent the contents of the file to standard out, the screen. if the the file does not exist, cat will send an error message to standard error, newfile STDERR and STDOUT example cat /tmp/file 1> newfile 2> errorfile if the file exists, the cat command will sent the contents of the file to standard out, newfile . if the the file does not exist, cat will send an error message to standard error, errorfile STDERR and SDTOUT example (special case, both sent to same file) In this example, we are redirecting both standard out and erro to the same file. Read the cat command like this: send the contents of /tmp/file to STDOUT (which is newfile) and send STDERR to the same place that STDOUT is going cat /tmp/file 1> newfile 2>&1 if the file exists, the cat command will sent the contents of the file to standard out, newfile . if the the file does not exist, cat will send an error message to standard error, which is the same as STDOUT, newfile. CAREFUL!!! left to right order matters!!! the following command line is NOT like the previous: cat /tmp/file 2>&1 1> newfile read this command left to right.... while running the cat command send STDERR to where STDOUT is going (STDOUT is STILL WRITING TO THE SCREEN!!!!!) and send the contents of the file to STDOUT, which is finally send to newfile. basically, at the time STDERR was sent to STDOUT, STDOUT was still the screen, only later is STDOUT send to a file. STDERR is not effected by the late redirection of STDOUT </pre> One more more note. inplace of 1> you can simply use >. > without a number is implicitly STDOUT. STDIN is a lot simpler. many programs can take file input for STDIN reather then from keyboard. also many programs can take STDIN inplace of command line parms. back to cat. everyone knows that this writes the file to STDOUT cat filename the exact same thing can be done as cat < filename or you can use cat to copy a file cat < originalfile > copyOfFile EditThisPage BackLinks PageInfo Pages like this Attachments RSS/Atom last changed on Fri Oct 27 22:44:23 2006 |
UpdatedPages· MythwebFlash last changed on Tue Sep 7 08:01:14 2010· HauppaugeThreeFiftyInstallation last changed on Tue Sep 7 07:59:50 2010 · MythStreamTV last changed on Tue Sep 7 07:58:13 2010 · UsingSambaHowto last changed on Tue Sep 7 07:57:01 2010 · TVOverScanHowto last changed on Tue Sep 7 07:53:19 2010 · TroubleShooting last changed on Mon Sep 6 15:33:02 2010 · Links last changed on Mon Sep 6 15:31:25 2010 · KnoppMythInstall last changed on Mon Sep 6 15:29:41 2010 · HowTo last changed on Mon Sep 6 15:26:44 2010 · TinnyAudioPVR150 last changed on Mon Sep 6 14:42:38 2010 · KnoppmythDownloads last changed on Sun Sep 5 22:27:51 2010 · LinuxTips last changed on Fri Sep 3 12:44:17 2010 · RepairingMythConvergDB last changed on Wed Sep 1 01:56:32 2010 · KnoppMythWiki last changed on Sun Aug 29 14:22:57 2010 · R5A12DvdRipping last changed on Fri Aug 27 22:24:09 2010 · HVR950HowTo last changed on Mon Aug 23 11:00:20 2010 · MythVodkaHowTo last changed on Mon Aug 23 00:48:53 2010 · x11vncHowTo last changed on Tue Aug 17 08:20:17 2010 · PickingComponents last changed on Tue Aug 17 08:19:41 2010 · MediaMVP_LinuxHOWTO last changed on Tue Aug 17 08:17:10 2010 · webminhowto last changed on Tue Aug 17 08:11:10 2010 · MythTVBurn_Scripts_HowTo last changed on Mon Aug 16 15:44:19 2010 · EditThisPage last changed on Wed Aug 4 04:10:39 2010 · R5.5/R6.x Differences Table and Equivalent Commands last changed on Wed Aug 4 00:27:20 2010 · Media_Center_Edition_Remote_Control last changed on Tue Aug 3 08:19:13 2010 · kworld115HowTo last changed on Tue Aug 3 08:12:26 2010 |
| sitemap | | |