Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

1 Answer 1

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
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

 
discard

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.