Vi replacement command usage exercise environment www.2cto.com RedHat Linux 9 + VWWare 8.0 + SSH 3.2.9 question suppose there is a CSV (comma separated value) file, which contains some information we need, however, the format is incorrect. Currently, the column sequence of data is: name, company name, abbreviated state name, and zip code. Now we want to regroup the data, for use in one of our software, www.2cto.com needs to be in the format of: name, abbreviated state name-zip code, company name. That is to say, we need to adjust the column order and combine two columns to form a new column. In addition, our software cannot accept any spaces (including spaces and tabs) before and after the comma. Therefore, we must remove all spaces before and after the comma. The original file is like this: Bill Jones ,??? HI-TEK Corporation ,? CA, 95011 Sharon Lee Smith ,? Design Works inconfigurated ,? CAS, 95012 B. Amos? ?,? Hill Street Cafe ,? CAS, 95013 Alexander Weatherworth ,? The Crafts Store ,? CA, 95014 we want to make it look like this: Bill Jones, CA 95011, HI-TEK Corporation Sharon Lee Smith, CA 95012, Design Works inreceivated B. amos, CA 95013, Hill Street Cafe Alexander Weatherworth, CA 95014, The Crafts Store solution Step 1: Save The source file as a source file, for example, test.txt Step 2: Upload test.txt to Linux. Here you can use The SSH file upload function. Step 3: Open test.txt with vi Step 4: execute the following command (enter a colon when entering the command, exit and save and enter wq, and exit without saving and Use q or q !): 1. Remove all question marks (?) [Plain] % s /? // G 2 remove all spaces before and after the comma [plain] % s/[\ t] *, [\ t] */, /g 3 implementation function [plain] % s/\ ([^.] * \), \ ([^.] * \), \ ([^.] * \), \ ([^.] * \)/\ 1, \ 3 \ 4, \ 2/g Implementation Effect