Shell Scripting related

Source: Internet
Author: User

Issue 1: Read the same line of two files simultaneously and insert the rows of two files into the same text

# cat aaa1a2a3a4# Cat bbb1b2b3/# vim aa.sh#!/bin/bashwhile read-u3 i && read-u4 j;doecho $i $jdone >cc 3<a A 4<bb#./aa.sh# cat CCA1 b1a2 b2a3 b3/


Note that READ-U3 I reads the contents from the file Descriptor 3 and assigns the value to the $i variable. The 3<AA representative reads the contents from the AA and redirects to the file descriptor 3 that the >CC represents the output of the while execution is redirected out to CC in 3<AA 4<BB written in the while, which is equivalent to only the while statement being redirected, while the end of the 3,4 would have been gone. If you use EXEC 3<aa 4<BB in front of the while, the redirected 3,4 will persist from exec until the end of the script. If you need to use AA,BB only in while, it is the best way to do it now. If you want to continue to access after while, consider the way exec 3<aa. The overall process of the statement is: continuously from the AA and BB to read the contents of I, J, and then printed with Echo, and the results are continuously appended to CC. This loop is executed until at least one of the end of the file is encountered in AA or BB. The script can be used for merging, splicing multiple text content for a long time useless 51cto write things, because the feeling of the editor is very bad, so long time again use found the original is not good use, perhaps I will not use it. How do I cancel this script format? Looking for a half day can not find the way to cancel.


Shell Scripting related

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.