14,954
edits
| Line 48: | Line 48: | ||
=== Merge multiple plain text files === | === Merge multiple plain text files === | ||
Step1: check the last line of text file is newline<ref>[https://stackoverflow.com/questions/34943632/linux-check-if-there-is-a-newline-at-the-end-of-a-file eof - Linux - check if there is a newline at the end of a file - Stack Overflow]</ref> | |||
* {{kbd | key=<nowiki>tail -c 1 file.txt</nowiki>}} on {{Linux}}. Parameter "-c <span style="text-decoration: underline;">number</span>: The location is <span style="text-decoration: underline;">number</span> bytes." quoted from the [http://man7.org/linux/man-pages/man1/tail.1.html commands manual]. If the last line is newline, returned result will be empty. | |||
Step2: Merge the content | |||
* {{kbd | key=<nowiki>copy *.txt > bundle.txt </nowiki>}} or {{kbd | key=<nowiki>copy file1.txt file2.txt > bundle.txt </nowiki>}} for {{Win}} | * {{kbd | key=<nowiki>copy *.txt > bundle.txt </nowiki>}} or {{kbd | key=<nowiki>copy file1.txt file2.txt > bundle.txt </nowiki>}} for {{Win}} | ||
* {{kbd | key=<nowiki>cat *.txt > bundle.txt </nowiki>}} or {{kbd | key=<nowiki>cat file1.txt file2.txt > bundle.txt </nowiki>}} for {{Linux}}<ref>[http://www.maclife.com/article/columns/terminal_101_join_multiple_files_together_cat Terminal 101: Join Multiple Files Together with Cat]</ref><ref>[https://unix.stackexchange.com/questions/3770/how-to-merge-all-text-files-in-a-directory-into-one How to merge all (text) files in a directory into one? - Unix & Linux Stack Exchange]</ref> | * {{kbd | key=<nowiki>cat *.txt > bundle.txt </nowiki>}} or {{kbd | key=<nowiki>cat file1.txt file2.txt > bundle.txt </nowiki>}} for {{Linux}}<ref>[http://www.maclife.com/article/columns/terminal_101_join_multiple_files_together_cat Terminal 101: Join Multiple Files Together with Cat]</ref><ref>[https://unix.stackexchange.com/questions/3770/how-to-merge-all-text-files-in-a-directory-into-one How to merge all (text) files in a directory into one? - Unix & Linux Stack Exchange]</ref> | ||