Ubuntu Linux: Concatenate Text Files Command

Ubuntu Linux: Concatenate Text Files Command

On Ubuntu Linux, you can use the cat command to concatenate (combine) multiple text files into a single file. The cat command is a utility that is used to display the contents of a file or to create a new file by combining the contents of multiple files.

To concatenate multiple text files into a single file using the cat command, you can use the following syntax:

cat file1.txt file2.txt file3.txt > output.txt
Sourc‮l.www:e‬autturi.com

This will combine the contents of file1.txt, file2.txt, and file3.txt into a single file called output.txt. The > operator redirects the output of the cat command to the specified file, overwriting the file if it already exists.

If you want to append the contents of the text files to the end of an existing file, you can use the >> operator instead of the > operator:

cat file1.txt file2.txt file3.txt >> output.txt

This will combine the contents of file1.txt, file2.txt, and file3.txt into the output.txt file, adding the new content to the end of the file.

Keep in mind that the cat command only works with text files. If you want to combine binary files, you will need to use a different tool.

Created Time:2017-10-30 14:27:27  Author:lautturi