Input / Output Redirection…!!! Presented By :- Akash Patel

Input / Output Redirection

Presented By :-  Akash Patel


Three standard file descriptors :-

1. stdin 0 – Standard input to the program.
2. stdout 1 – Standard output from the program.
3. stderr 2 – Standard error output from the program.

Purpose & Command :-

                                                         
1) redirect std output to filename:-                        > filename or 1> filename
2) append std out to filename:-                              >> filename
3) append std out and std error to filename :-        >> filename 2>&1 or 1>> filename 2>&1
4) take input from filename :-                                < filename or 0 < filename
5) redirect std error to filename :-                          2> filename
6) redirect std out and std error to filename :- 1> filename 2>&1 or > filename 2>&1
   

Some examples of using I/O redirection :-

1. Simple output _ errors :-


2. Output in file _ error in display :-



3. Appending output in file :-




4. Redirect errors in file :-



5. Append errors as previous :-



6. Discarding errors _ send to null=0 :-



7. Save output _ error in one file :-



8. Save output _ error in seprate file :-


Leave a Reply

Your email address will not be published.

%d bloggers like this: