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.

How can I append a command's output to multiple files?

For example, the command man ls, I need to append its output into three different text files using one command in terminal.

share|improve this question
    
What you want to do three different files containing the output of man ls? I'm almost sure that nobody will delete that manual page... –  Radu Rădeanu May 24 at 17:30
    
@RaduRădeanu it is just an example –  nux May 24 at 17:55

1 Answer 1

up vote 6 down vote accepted

You can use tee command .

Command :

man ls | tee -a file1 file2 file3 

Result : man ls command's output will be appended into file1 file2 file3

For more info : man tee

Reference : Site

share|improve this answer
1  
If you're using zsh you can do this: echo "Hello World" > {file1,file2,file3} but using tee always works too –  Flint May 17 at 2:23
    
@jobin no i correct my answer , Avinash was right –  nux May 18 at 14:27
    
good that you corrected, +1! –  i08in May 18 at 14:28
    
@nux i revert back my downvotes. –  Avinash Raj May 18 at 15:10

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.