read command in Linux with Examples
read command in Linux system is used to read from a file descriptor. Basically, this command read up the total number of bytes from the specified file descriptor into the buffer. If the number or count is zero then this command may detect the errors. But on success, it returns the number of bytes read. Zero indicates the end of the file. If some errors found then it returns -1.
Syntax:
read
Examples:
- read command without any option: The read command asks for the user’s input and exit once the user provides some input.
- In the following example we are acquiring the user’s name and then showing the user’s name with a greeting.
echo "what is your name..?";read name;echo "hello $name"
Recommended Posts:
- pwd command in Linux with Examples
- cmp Command in Linux with examples
- ip command in Linux with examples
- du command in Linux with examples
- rev command in Linux with Examples
- until command in Linux with Examples
- df command in Linux with Examples
- cd command in Linux with Examples
- let command in Linux with Examples
- arp command in Linux with examples
- gdb command in Linux with examples
- tty command in Linux with examples
- fg command in Linux with examples
- bg command in Linux with Examples
- cut command in Linux with examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.







