How to read and write of a open file?

Showing Answers 1 - 9 of 9 Answers

muru

  • Nov 22nd, 2006
 

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

  Was this answer useful?  Yes

harish

  • Dec 4th, 2006
 

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;

  Was this answer useful?  Yes

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.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions