haughtonomous
haughtonomous

Reputation: 4850

How do I make grep output to a file?

I'm trying to find some stuff in a large number of text files, and I want the output to be in a file so I can read it at leisure:

grep -i 'alter table' *.sql >> tables.txt

grep (this is the Windows version of the Gnu tool) complains at the >>. I've tried piping and all the rest, and there doesn't saeem to be an option to define an output file either.

Any ideas?

Upvotes: 2

Views: 25919

Answers (2)

now
now

Reputation: 5027

Reviving this old question, but it's among the first Google results.

grep outputs differently, so I needed to add this option to ouptut the results to a file:

grep --line-buffered

Source

Upvotes: 5

foxidrive
foxidrive

Reputation: 41234

This works here:

grep -i "other something" *.txt >> tables.txt

Upvotes: 3

Related Questions