Use of the Shell's read

Source: Internet
Author: User
Tags set time

The read command is used to receive input from the keyboard's standard input and other files, and after the input is entered, the Read command places the data in a standard variable.

Example 1:

#!/bin/bash

Read-s-P "Enter you password:" Password #-s: does not display input,-P: In the Read command line refers to

echo "Hello,your password is $password" to set a hint


Example 2:

#!/bin/bash

Echo-n "Enter Your Name:"

Read name #从键盘输入

echo "hello! $name "


#!/bin/bash

Read-t 5-p "Enter Your Name:" Name #-t: Set time limit

echo "This is $name"


Example 3: Read line

#!/bin/bash

File=/etc/fstab

I=1

Cat $file | While read line

Do

Echo $i # # # $line

((i++))

Done


This article from "10,000 years too long, seize" blog, please be sure to keep this source http://zengwj1949.blog.51cto.com/10747365/1924434

Use of the Shell's read

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.