Rajeev
Rajeev

Reputation: 46919

Output contents to two different files

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

Answers (3)

Perry
Perry

Reputation: 4495

In addition to the other suggested methods: you can also just cp the output file after executing the ls.

Upvotes: 1

Marius
Marius

Reputation: 101

You can use tee ls /tmp | tee -a a.txt b.txt

edit: okay DarkDust wars faster :)

Upvotes: 3

DarkDust
DarkDust

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

Related Questions