Let's talk about the applicable scenarios. The marketing department wants to see the activity of "scalper" users in some products and the use of coupons for "scalper", and then sends an Excel file, copy the file to notepad ++ in the following format:
ID name
Price
1 name1
Price1
2 name2
Price2
3 name3
Price3
4 name4
Price4
5 name5
Price5
6 name6
Price6
7 name7
Price7
8 name8
Price8
9 name9
Price9
During query, all IDs are organized into one row and written as (1, 2..., 8, 9). This requires the following:
First, delete the first line title, sed '1d 'ids.txt;
Second, only the first column is displayed. awk-F' \ t' {print $1 }';
Third, separate the first column with commas (,), and then use the commas (,) to separate them '',';
Fourth, add the Left and Right brackets and SED's/^/(/'before and after the result in step 3 /(/'.
Group these four steps together and execute: sed '1d 'ids.txt | awk-F' \ t' {print $1} '| tr' \ n '', '| SED's/, $/);/' | SED's/^/(/'> OK .txt
(, 9 );
Then write an SQL statement and splice it with the file. When the data volume is small, the effect is not obvious. When processing tens of millions of data and one text has several GB,
The powerful text processing function of Linux is displayed.