Reputation: 69
I want to grep the same output to multiple files. example : grep "some string" > file 1 and file 2, i want this. Can anyone help me? Thanks in Advance.
Upvotes: 0
Views: 854
Reputation: 41456
You can also do it with awk
awk '/some string/ {print | "tee file1"}' >file2 somefile
Upvotes: 0
Reputation: 123508
You can say:
grep "some string" somefile | tee file1 | tee file2
This would redirect the result of grep
to file1
and file2
and also display that on screen.
To avoid the results being displayed on the screen, you could say:
grep "some string" somefile | tee file1 > file2
Upvotes: 1