GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Operating System  >  Unix Programming
Go To First  |  Previous Question  |  Next Question 
 Unix Programming  |  Question 10 of 43    Print  
How to read and write of a open file?

  
Total Answers and Comments: 3 Last Update: November 13, 2009     Asked by: Sivaram 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: sarikamagdum
 
Read from file:

cat file_name

Or on terminal pagewise read as :

more file_name.

Write to file :

echo "`cmd`" > file_name.

Where cmd= any executable UNIX command.
             >  = redirect the o/p.
            >> = append to file_name.

Above answer was rated as good by the following members:
getpreetam
November 22, 2006 05:32:21   #1  
muru        

RE: How to read and write of a open file?
To read from a file: exec 5<&0 # standard input (your terminal) is denoted by file descriptor 0. It is assigned to 5 exec 0> samplefile # line is appended to samplefile done
 
Is this answer useful? Yes | No
December 04, 2006 08:55:37   #2  
harish        

RE: How to read and write of a open file?
we can use the read and write system call for thatread(fd buff BUF_SIZE);write(fd buff strlen(buff));assuming buff is a char string;
 
Is this answer useful? Yes | No
November 12, 2009 10:07:38   #3  
sarikamagdum Member Since: November 2009   Contribution: 1    

RE: How to read and write of a open file?
Read from file:

cat file_name

Or on terminal pagewise read as :

more file_name.

Write to file :

echo "`cmd`" > file_name.

Where cmd any executable UNIX command.
> redirect the o/p.
>> append to file_name.

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape