read command in Linux with Examples Last Updated : 25 Sep, 2024 Comments Improve Suggest changes Like Article Like Report read command in the Linux system is used to read from a file descriptor. This command reads up the total number of bytes from the specified file descriptor into the buffer. If the number or count is zero, this command may detect errors. But on success, it returns the number of bytes read. Zero indicates the end of the file. If some errors are found then it returns -1. Let’s look deeper into its usage, syntax, options, and some common examples.SyntaxreadThe read command takes the user's input and stores it into a variable that can be referenced later in the script.Basic read Command ExampleOptions for the read CommandOptionsDescription-pDisplays a prompt before reading input.-tSets a timeout to wait for input.-nLimits the number of characters to read.-sDisables echoing the input (useful for password entry).-dDefines a delimiter other than a newline.read Command Examples in Linuxread 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"ConclusionThe read command's ability to capture user input, read files, and handle input with various options makes it essential for interactive and automated scripts. By mastering this command and its various flags, you can make your shell scripts more dynamic and user-friendly. Comment More infoAdvertise with us R rahulkumarmandal Follow Improve Article Tags : Linux-Unix linux-command Linux-Shell-Commands Similar Reads Paste command in Linux with examples Paste command is one of the useful commands in Unix or Linux operating system. It is used to join files horizontally (parallel merging) by outputting lines consisting of lines from each file specified, separated by tab as delimiter, to the standard output. When no file is specified, or put dash ("-" 6 min read pidof Command in Linux with Examples pidof command is used to find out the process IDs of a specific running program. It is basically an identification number that is automatically assigned to each process when it is created. Syntax: pidof [options] program1 program2 ... programNWorking with Pidof Command 1. To find pid of any process 2 min read How to Check Network Connectivity in Linux | ping Command Ensuring a stable and reliable internet connection is crucial for seamless navigation and efficient communication in the world of Linux. The "ping" command is a powerful tool that allows users to check the status of their internet connection and diagnose network-related issues. In this article, we w 7 min read Pinky command in Linux with Examples Pinky command is a user information lookup command which gives details of all the users logged in. This tool is generally used by system administrators. It is similar to the finger tool but in many Linux, Systems pinky comes pre-installed while finger doesn't, so this command is useful in case you d 2 min read pmap command in Linux with Examples The pmap command in Linux is a powerful utility used to display the memory map of a process. A memory map provides insight into how memory is allocated and distributed within a running process. This can be incredibly useful for developers and system administrators when debugging memory issues, optim 3 min read halt, poweroff and reboot Commands in Linux In Linux systems, the halt, poweroff, and reboot commands are essential tools for controlling the system's hardware by stopping the CPU, shutting down the system, or restarting it. These commands are typically restricted to superusers, as they involve critical actions that impact the system hardware 4 min read printf command in Linux with Examples The 'printf' command in Linux is a versatile tool used to display formatted text, numbers, or other data types directly in the terminal. Like the 'printf' function in programming languages like C, the Linux printf command allows users to format output with great precision, making it ideal for script 4 min read How to List Running Processes in Linux | ps Command As we all know Linux is a multitasking and multi-user system. So, it allows multiple processes to operate simultaneously without interfering with each other. Process is one of the important fundamental concepts of the Linux OS. A process is an executing instance of a program that carries out differe 10 min read How to Display Current Working Directory in Linux | pwd Command The 'pwd,' which stands for "print working directory." In this article, we will delve into the 'pwd' command, exploring its functionality, usage, and various examples. It prints the path of the working directory, starting from the root. pwd is shell built-in command(pwd) or an actual binary(/bin/pwd 4 min read ranlib command in Linux with Examples ranlib command in Linux is used to generate index to archive. ranlib generates an index to the contents of an archive and it will be stored in the archive. The index lists each symbol defined by a member of an archive which is simply a relocatable object file. You may use 'nm -s' or 'nm âprint-armap 4 min read Like