简体   繁体   中英

Use grep to select lines from a .csv file

I have a.csv file with data like the following:

English short name (upper/lower case);Alpha-2 code;Alpha-3 code;Numeric code;ISO 3166-2 codes
"Afghanistan";AF;AFG;004;ISO 3166-2:AF
"Åland Islands";AX;ALA;248;ISO 3166-2:AX
"Albania";AL;ALB;008;ISO 3166-2:AL

Now, I need to select all the lines where the first two characters in the three character code (Alpha-3 code, 3rd column) are not the same as the two characters in the two character code (Alpha-2 code, 2nd column).

I am not able to figure out how I can compare these two words with grep and regex.

I have a.csv file with data like the following:

English short name (upper/lower case);Alpha-2 code;Alpha-3 code;Numeric code;ISO 3166-2 codes
"Afghanistan";AF;AFG;004;ISO 3166-2:AF
"Åland Islands";AX;ALA;248;ISO 3166-2:AX
"Albania";AL;ALB;008;ISO 3166-2:AL

Now, I need to select all the lines where the first two characters in the three character code (Alpha-3 code, 3rd column) are not the same as the two characters in the two character code (Alpha-2 code, 2nd column).

I am not able to figure out how I can compare these two words with grep and regex.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM