4

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.

2
  • 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... May 24, 2014 at 17:30
  • @RaduRădeanu it is just an example
    – nux
    May 24, 2014 at 17:55

1 Answer 1

7

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

4
  • 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, 2014 at 2:23
  • @jobin no i correct my answer , Avinash was right
    – nux
    May 18, 2014 at 14:27
  • good that you corrected, +1!
    – jobin
    May 18, 2014 at 14:28
  • @nux i revert back my downvotes. May 18, 2014 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .