How do I concatenates the text files called first.doc and second.doc and writes the result to final.doc under Ubuntu Linux operating systems?
You need to use the cat command to show a text file or concatenates the text files under Ubuntu or Unix like operating systems. The syntax is as follows to see the contents of the file foo.txt in the current directory to screen:
To concatenates the text files the syntax is:
cat file1 file2 > file3
The output redirector (>) symbol used to redirect output of two files to the file3.
Create a file called first.doc, enter:
echo 'This is a test and stored in first.doc file.' > first.doc cat first.doc
Create a file called second.doc, enter:
echo 'This is a test and stored in second.doc file.' > second.doc cat second.doc
Verify both file exists in the current directory with the ls command:
To concatenates both files and store the result to final.doc, enter:
cat first.doc second.doc > final.doc ls -l *.doc cat final.doc