Merge multiple text files

Source: Internet
Author: User

Merge multiple text files

Small Method for merging multiple text files

How can I quickly Merge multiple text files (such as txt?

This is actually very simple.

(1) Merge multiple txt files under WIN

Lab:

Create multiple txt files as follows:

The content is as follows:

1:

2: B

3: c

4: d

Now we need to combine these four txt files into a ". SQL" file.

The merged results are as follows:

(2) Merge multiple sh files in LINUX

LINUX is actually simpler. Think about how to clear a log file?

You can use this command, for example, $ cat/dev/null>/var/adm/syslog. log. It seems that the cat command may merge multiple files. Here is an experiment.

 

Use the same method to build three ". sh" files, as shown below:

1:

2: B

3: c

4: d

Lab:

New. sh is the merged result.

(3) use the word "merge" to derive the SQL field merging

In SQL, we can use the wm_concat function to merge fields.

 

Lab:

Use the emp table under the scott user in the experiment

 

SQL> select * from emp;

-- First, let's take a look at all the content of the emp table.

EMPNO JOB MGR HIREDATE SAL COMM DEPTNO ENAME

----------------------------------------------------------------------------------

7369 CLERK 7902 800.00 20

7499 DBA 7698 1600.00 300.00 30

7521 DBA 7698 1250.00 500.00 30

7566 MANAGER 7839 2975.00 20

7654 DBA 7698 1250.00 1400.00 30

7698 DBA 7839 2850.00 30

7782 MANAGER 7839 2450.00 10

7788 ANALYST 7566 1987/4/19 3000.00 20

7839 PRESIDENT 1981/11/17 5000.00 10

7844 DBA 7698 1500.00 0.00 30

7876 CLERK 7788 1987/5/23 1100.00 20

7900 DBA 7698 950.00 30

7902 ANALYST 7566 3000.00 20

7934 CLERK 7782 1982/1/23 1300.00 10

14 rows selected

 

SQL> select DEPTNO, wm_concat (job) jobs from emp group by deptno;

-- View the names of all positions in the same department

DEPTNO JOBS

---------------------------------------------------------------------------

10 MANAGER, CLERK, PRESIDENT

20 CLERK, ANALYST, CLERK, ANALYST, MANAGER

30 DBA, DBA

Summary:

To merge txt files, run the following command:

1. win: type *. sh> new. sh

2. linux: cat *. sh> new. sh

Supplement: function for merging multiple fields in SQL: wm_concat ()

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.