Reputation: 46919
How to redirect the out of ls /tmp command to more than one file
i.e, the out put needs to be on ls /tmp > a.txt and b.txt
Upvotes: 2
Views: 83
Reputation: 4495
In addition to the other suggested methods: you can also just cp the output file after executing the ls.
Upvotes: 1
Reputation: 101
You can use tee ls /tmp | tee -a a.txt b.txt
edit: okay DarkDust wars faster :)
Upvotes: 3
Reputation: 92335
Use tee
:
# This way you will see the output.
ls /tmp | tee file1.txt file2.txt
# With this line you won't.
ls /tmp | tee file1.txt file2.txt >/dev/null
Upvotes: 6