Shell--read-u

Source: Internet
Author: User

Transferred from: https://zhidao.baidu.com/question/357781350.html

 while Read-u3 i && Read-u4 J;  Do Echo  done34<bfile
Read-u3 I means to read a row of data in the I variable from FD # 3rd (file descriptor, filename descriptor), so you know what Read-u4 J means.

and 3<afile means redirect afile to 3rd FD, so you understand 4<bfile

So, the entire code


Done 3<afile 4<bfile
Reads the contents from Afile and bfile to I, J, and then uses the


For example, your afile content is
A
B
C

The content of bfile is
1
2
3
4

Then this program will print
A 1
B 2
C 3

Ask
Why write this 3<afile, not exec 3<afile, and not in front of the loop?
Chase Answer
Using the current notation, it is equivalent to redirecting only the while statement, while the 3,4 is gone after the end. If you use EXEC 3<afile 4<bfile in front of the while, the redirected  3,4 will persist from exec until the end of the script.

So for your code, since only in the while need to use afile bfile, that is the best way to do it now. If you want to continue to access after while, consider the way exec 3<afile.

Shell--read-u

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.