Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

read(2) [plan9 man page]

READ(2) 							System Calls Manual							   READ(2)

read, readn, write - read or write file SYNOPSIS
#include <u.h> #include <libc.h> long read(int fd, void *buf, long nbytes) long readn(int fd, void *buf, long nbytes) long write(int fd, void *buf, long nbytes) DESCRIPTION
Read reads nbytes bytes of data from the offset in the file associated with fd into memory at buf. The offset is advanced by the number of bytes read. It is not guaranteed that all nbytes bytes will be read; for example if the file refers to the console, at most one line will be returned. In any event the number of characters read is returned. A return value of 0 is conventionally interpreted as end of file. Readn is just like read, but does successive read calls until nbytes have been read, or a read system call returns a non-positive count. Write writes nbytes bytes of data starting at buf to the file associated with fd at the file offset. The offset is advanced by the number of bytes written. The number of characters actually written is returned. It should be regarded as an error if this is not the same as requested. SOURCE
/sys/src/libc/9syscall /sys/src/libc/port/readn.c SEE ALSO
intro(2), open(2), dup(2), pipe(2) DIAGNOSTICS
These functions set errstr. READ(2)

Check Out this Related Man Page

READ(2) 							System Calls Manual							   READ(2)

read - read input SYNOPSIS
#include <sys/types.h> #include <unistd.h> ssize_t read(int d, void *buf, size_t nbytes) DESCRIPTION
Read attempts to read nbytes of data from the object referenced by the descriptor d into the buffer pointed to by buf. On objects capable of seeking, the read starts at a position given by the pointer associated with d (see lseek(2)). Upon return from read, the pointer is incremented by the number of bytes actually read. Objects that are not capable of seeking always read from the current position. The value of the pointer associated with such an object is undefined. Upon successful completion, read return the number of bytes actually read and placed in the buffer. The system guarantees to read the num- ber of bytes requested if the descriptor references a normal file that has that many bytes left before the end-of-file, but in no other case. If the returned value is 0, then end-of-file has been reached. RETURN VALUE
If successful, the number of bytes actually read is returned. Otherwise, a -1 is returned and the global variable errno is set to indicate the error. ERRORS
Read will fail if one or more of the following are true: [EBADF] D is not a valid descriptor open for reading. [EFAULT] Buf points outside the allocated address space. [EIO] An I/O error occurred while reading from the file system. [EINTR] A read from a slow device was interrupted before any data arrived by the delivery of a signal. [EAGAIN] The file was marked for non-blocking I/O, and no data were ready to be read. SEE ALSO
dup(2), fcntl(2), open(2), pipe(2), write(2). 4th Berkeley Distribution May 23, 1986 READ(2)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

what can I get the posix standard?

I wanted study and write a unix like system. who can help me. ------------- Removed the garbled characters... not sure why they were there... (2 Replies)
Discussion started by: crashsky
2 Replies

2. UNIX for Advanced & Expert Users

smart question

eg. : there is a file - 322 bytes, how can I (or you) view just a half of file (161 bytes)? (3 Replies)
Discussion started by: zylwyz
3 Replies

3. UNIX for Advanced & Expert Users

EIF file

Hi, What is a EIF file ? Many thanks before. (2 Replies)
Discussion started by: big123456
2 Replies

4. UNIX for Advanced & Expert Users

please help

Dear friends, I am writing csh script to automate some process. for that , i have one bulk dat file containing hex data . i want to write perticular line by using idno into separate file. for this solution grep command is enough are any commands are there. my dat file has lihe... (9 Replies)
Discussion started by: rajan_ka1
9 Replies

5. UNIX for Advanced & Expert Users

how to read each letter from file and store it in variable.

Dear friends, i am writing csh script i have one dat file containing following this. 08FD3 03A26 000FA0 FFFF0 BBA0F 00000 00000 from the above file i want to read each letter and store it in one variable. how it is possible. please help (7 Replies)
Discussion started by: rajan_ka1
7 Replies

6. UNIX for Advanced & Expert Users

if (( $# != 1 )) ---- what will this return

Hi this is an existing code written by somebody. Please help me in understanding the meaning of this if (( $# != 1 )) (3 Replies)
Discussion started by: satgur
3 Replies

7. UNIX for Advanced & Expert Users

Apache22 not starting

I am getting this error message once I added some lines to a directive in my httpd.conf file. I double checked and made sure their weren't any typos Snytax error line 468 Invlaid command PerlHandler perhaps misspelled or defined by a module not included in the server configuration. Here is what I... (10 Replies)
Discussion started by: rbizzell
10 Replies

8. UNIX for Advanced & Expert Users

how to read this

Dear All, I have some need, I want know how to read this file, and how to get IP from remote that connect to my system my is ( and how can I see what they doing in my system. thank's before Regards, heru (5 Replies)
Discussion started by: heru_90
5 Replies

9. UNIX for Advanced & Expert Users

HELP! Need 2 Write a program which will read in a tax rate (as a percentage) and the

I need this ASAP...don't know where else to turn... Thanx in advance :) (2 Replies)
Discussion started by: 1TruLuv
2 Replies

10. UNIX for Advanced & Expert Users

Can anyone give more details about the system calls?

Hello, Please can any one explain about the parameters to the write systemcalls?? How are they passed?? and how is the address of the user buffer is handled by the kenel?? for ex: write(fd,buf,count); How does the kernel handles this user buffer address?? After write does the kernel write... (1 Reply)
Discussion started by: prakash.kudreka
1 Replies

11. UNIX for Advanced & Expert Users

foreign characters in flat file

Hey, Is there anyway I anks, Pocha (12 Replies)
Discussion started by: pochaman
12 Replies

12. Shell Programming and Scripting

PDKSH dual std input threads

Hi All, I'm trying to read from two files at the same time, but the second READ is failing, giving no value. Obvious STDIN is being used by the first "while read", so how can I retrieve a value from a second file within the loop ?? IFS=" ," cat $DATAFILE | while read curdate currentcksum... (3 Replies)
Discussion started by: adrianmarsh
3 Replies

13. UNIX for Advanced & Expert Users

read() wont allow me to read files larger than 2 gig (on a 64bit)

Hi the following c-code utilizing the 'read()' man 2 read method cant read in files larger that 2gig. Hi I've found a strange problem on ubuntu64bit, that limits the data you are allowed to allocate on a 64bit platform using the c function 'read()' The following program wont allow to allocate... (14 Replies)
Discussion started by: monkeyking
14 Replies

14. UNIX for Advanced & Expert Users

Tokenise every line read

Read a file line by line and extract the 3rd and 6th token of each line read. PLease note that each line read is to be tokensied based onto "/" "\" ":" Kindly help me with a script? (5 Replies)
Discussion started by: skyineyes
5 Replies

15. Programming

Error with compiling

Hi guys. I have a header file: unp.h like this: #ifndef _UNP_H_ #define _UNP_H_ extern ssize_t readn(int filedes, void *buff, size_t nbytes); extern ssize_t writen(int filedes, const void *buff, size_t nbytes); extern void err_quit(const char *msg); #define TRUE 1 #define FALSE 0 ... (2 Replies)
Discussion started by: majid.merkava
2 Replies