GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Operating System  >  Unix Commands
Go To First  |  Previous Question  |  Next Question 
 Unix Commands  |  Question 5 of 73    Print  
What is redirection?
Directing the flow of data to the file or from the file for input or output.
Example :  ls > wc



  
Total Answers and Comments: 6 Last Update: August 09, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
December 20, 2005 05:20:21   #1  
vijayKumar D.S        

RE: What is redirection?

Redirection is a feature in Unix where the data from the standard out put or a file,so on.can be redirected i.e divert to a file or a program and vice versa.

>  -- out put redirection

>> -- out put redirectin(appending at the last)

< -- input redirection


 
Is this answer useful? Yes | No
March 28, 2007 11:43:32   #2  
Chiranjeevi Manne        

RE: What is redirection?
Redirection is the process of redirecting the output or directing input to a command

the redirection uses > , >>, <

Ex:
The output redirection symbols are useful for redirecting the output of a shell script in to a log file.

sh -x [shell_scrip] > [log_file]

the >> symbol is useful for appending output at the end of an existing file.

sh -x [shell_script] >> [log_file]

The < symbol is useful for inout redirection

cat < [file_name]  --> this command is similar to cat [file_name]

 
Is this answer useful? Yes | No
October 21, 2007 07:05:04   #3  
aman        

RE: What is redirection?
redirection in UNIX
it changes standard input in standard output
we can redirect our files accordingly
as
$cat my > you
so here i have redirected file (me) to u actually wt have done is i have change the standard input as well as standard output
here standard input is file MY
and standard output has been converted to file YOU
by default standard o/p is monitor
and standard i/p is keyboard
so check it
$cat my>you

 
Is this answer useful? Yes | No
December 14, 2007 11:49:46   #4  
vthegde Member Since: December 2007   Contribution: 5    

RE: What is redirection?
redirection is used to change normal behaviour of stdin, stdout, stderr. these are by default, identified by file descriptors 0,1,2.
 
Is this answer useful? Yes | No
May 07, 2008 00:58:49   #5  
wow_suraj Member Since: May 2008   Contribution: 15    

RE: What is redirection?

redirection is used to change the default input and output source.

'>' is used to redirect the output to location other than standard output terminal. If the location doesn't exist it will create one and clean the previous content before writing the output.


'>>' is used to append the output to location other than standard output terminal. If the given location doesn't exist it will create one and append the output.

'<' is used to redirect the input from source other than standard input device.


 
Is this answer useful? Yes | No
August 09, 2008 02:12:02   #6  
satyam.kumar2008 Member Since: August 2008   Contribution: 5    

RE: What is redirection?
Whenever we run a command on shell prompt we get some output on shell prompt.
In case we don't want to appear the output on the shell prompt we can redirect the output to the somewhere else. We can make the output which go into the file or may be directly to printer or we could make it disappear.

This is known as redirection.

$ ls > listing

The ' ls ' command would normally give you a directory listing. Since you have the ' > ' operator after the ' ls ' command, redirection would take place. What follows the ' > ' tells Unix where to redirect the output. In our case it would create a file named ' listing ' and write the directory listing in that file. You could view this file using any text editor or by using the cat command.

Note: If the file mentioned already exists, it is overwritten. So care should be taken to enter a proper name. In case you want to append to an existing file, then instead of the ' > ' operator you should use the ' >> ' operator. This would append to the file if it already exists, else it would create a new file by that name and then add the output to that newly created file.


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape