Grep: Copy all lines from log file into new file

Hello everyone. I have a log file that contains multiple domains:

I need to copy all of the lines that contain "www.thisdomain.com" from the log and output them into a new file. I've tried everything with little luck. Please help and thanks!

This is assuming it's an already static log file and you aren't "scraping" a file that's being written to at all times.

grep 'www\.thisdomain\.com' testing.txt >> tmp.txt

I forgot to mention that the match has to be in the cs-host field as domains can show up in cs-referer as well. My solution below and thanks for your contribution:

grep -E "(.) (.) (.) (.) (www\.raileurope\.com)" filename.log > newfile.log

The cs-host column is the 5th column in the log file.

Hi Aberli,

This is quite easy, lets say your file 'myfile.txt' contains some lines having --> www.thisdomain.com
and you need all the lines having www.thisdomain.com into a new file e.g. myfile_new.txt
Use the following command:

grep "www.thisdomain.com" myfile.txt >> myfile_new.txt

Regards,
Sumedha