Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

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
share|improve this answer
what is the usage of tee – naveen Nov 9 '13 at 7:32
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 posting your answer, you agree to the privacy policy and terms of service.

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