Merge multiple text files into one file: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 15: Line 15:


Step 5: Verify the merge
Step 5: Verify the merge
* count Number of Lines {{kbd | key=<nowiki>wc -l filename</nowiki>}}<ref>[https://www.tecmint.com/wc-command-examples/ 6 WC Command Examples to Count Number of Lines, Words, Characters in Linux]</ref>
* count number of lines {{kbd | key=<nowiki>wc -l filename</nowiki>}}<ref>[https://www.tecmint.com/wc-command-examples/ 6 WC Command Examples to Count Number of Lines, Words, Characters in Linux]</ref>


== References ==
== References ==

Revision as of 16:30, 30 January 2020

Steps

Step 1: check the last line of text file is newline[1]

Step 2: Merge the content

  • copy *.txt > bundle.txt or copy file1.txt file2.txt > bundle.txt on Win Os windows.png
  • cat *.txt > bundle.txt or cat file1.txt file2.txt > bundle.txt on Linux Os linux.png [2][3]

Step 3: (optional) Remove the duplicated lines

  • sort -us -o bundle_unique.txt bundle.txt[4] OS: Linux Os linux.png , cygwin of Win Os windows.png "-u means Unique keys; -s means stable sort; -o means output" quoted from sort manual.

Step 4: (optional) Remove the heading of CSV file

Step 5: Verify the merge

  • count number of lines wc -l filename[5]

References

<reference />