Match shell variable characters in awk

Source: Internet
Author: User

Problem: Now there are two scripts, I want to match the contents of File1 by File2
[email protected] home]# cat file13-1-1 potv=1,pota=0,potp=21-4-76 potv=1,pota=0,potp=12-1-2 potv=1,pota=1,potp= 13-1-4 potv=1,pota=1,potp=24-1-5 potv=1,pota=1,potp=27-1-2 potv=1,pota=1,potp=23-1-10 POTV=1,POTA=1,POTP=21-1-1 Potv=1,pota=2,potp=0

 

[email protected] home]# cat file21-1-12-1-22-1-33-1-44-1-5

  

Equivalent to the exact match of grep, but the grep-w ' 1-1-1 ' file1 implemented with awk implements the value with the for in loop, assigning the variable a substitution idea to change the match into a variable with a for in loop, and then match the replace for I in ' cat file2 ' doawk ' $1== ' ' $i ' "' {print $} ' file1 >> urfileDone
awk  ' $1== ' ' $i ' ' ' '          {print $} ' file1 the   single quotation mark in this paragraph is an act of de-justification that precisely matches characters in awk, The character needs to be quoted in double quotes: that is, awk ' $1== ' 1-1-1 ' {print $} ' test, so to pass the argument, use single quotation marks to de-enclose the double quotation mark to allow awk to recognize
Single-quote pairs appear in accordance with the nearest principle

  

Match shell variable characters in awk

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.