I have a directory employer/. In this there are 5 .txt files.

I want to combine the data from all 5 files and show into the command prompt using cat or create another file and save the result in that file. How can I do this?


First go to employer/ directory (using cd /path/to/employer/ command), then use one of the following commands:

cat file1.txt file2.txt file3.txt file4.txt file5.txt

or, simple:

cat *.txt

If you want to save the output in a new file, then you can use:

cat *.txt >new_file.txt

If you want both, to write the output to standard output and to a new file, then you can use:

cat *.txt | tee new_file.txt
| improve this answer | |
  • 1
    what is the usage of tee – naveen Nov 9 '13 at 7:32
  • 2
    I can not abstain to say this: please RTFM man tee. – Radu Rădeanu Nov 9 '13 at 7:36
  • @navee: tee writes its input to standard output and to a new file – Florian Diesch Nov 9 '13 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.