Re: how do i..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2004-08-22 at 18:31, Mr. Oberoi wrote:
> I see people still going on about my "five mistakes" mail... I am over
> it and willing to learn so could any one tell me how do i save the
> error results from the program(shell script) to a file. when i tried
> using pipe it only saves first line and rest of the mistakes get
> displayed on the screen! why is that and how can i fix it?
> thanks
>  
> 
> deepak oberoi
> 
Deepak,

There are two output channels, stdout and stderr.  You may redirect each
by doing the following:

scriptname > file1 2> file2

file1 will then contain the normal output from the script and file2
would contain any error output.

You can combine the output to a single file by doing the following:

scriptname > filename 2>&1

or

scriptname &> filename

In both cases, both standard output and error output will be redirected
to filename.

The one danger is that this form of redirection will overwrite the
file.  You can also do a pair of >> to "append" if the file already
exists.

BTW, the pipe character is used to "chain" the output of the command on
the left of the pipe as input to the command on the right of the pipe.

HTH,

--Rob




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux