The Wayback Machine - https://web.archive.org/web/20231217001221/https://www.geeksforgeeks.org/read-command-in-linux-with-examples/
Open In App
Related Articles

read command in Linux with Examples

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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"

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 24 May, 2019
Like Article
Save Article
Previous
Next
Similar Reads