Jump to content

read (Unix)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Wikieditor 2027 (talk | contribs) at 10:25, 23 July 2023 (Adding more detail). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
read
Operating systemUnix, Unix-like, Inferno
TypeCommand

read is a command found on Unix and Unix-like operating systems such as Linux. It reads a line of input from standard input or a file passed as an argument to its -u flag, and assigns it to a variable.

In Unix shells, like Bash, it is present as a shell built in function, and not as a separate executable file.[1]

Detail

#include <unistd.h>
ssize_t read(int fd, void* buffer, size_t count);

read() reads upto count bytes of data from file descriptor fd to buffer. On success number of bytes read is returned and file position is advanced by this number. It's possible that the number of bytes read is less than the count value.


References

  1. ^ "read command on the open group website".