0

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.

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

0

You can also do it with awk

awk '/some string/ {print | "tee file1"}' >file2 somefile

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.